Announcement Announcement Module
No announcement yet.
Adding validation on an annotated multiactioncontroller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding validation on an annotated multiactioncontroller

    Hi All,

    I am trying to understand Spring Annotated Style Controller and I am new to this.
    This is written in Spring MVC 2.5.

    I have a multiaction controller annotated like below. Now I wanted to add some custom validation
    and I added the Errors object on the method signature.

    	public String validateQualItems(
    			HttpServletRequest request,,
    			@RequestParam("lngTRN") long lngTRN,,
    			Errors error) {
    		if(lngTRN == 0){
    			error.reject("123", "TRN cannot be set to zero");
    			return "displayList.htm
    		//other sucess code here redirect:
    My form is like this. In my JSP, it is creating many forms so thats why I gave each form unique name.

    <form name="qa-form-182" action="validateQualItem.htm" method="post">
    		<label for="qaRemarks" class="label">QA Remarks:</label>
    		<textarea  rows="5" cols="23" id="qa-remarks"></textarea>
    	<input type="hidden" value="23" name="lngTRN" />
    	<p><input class="action-button" type="submit" value="Validate" name="validate"/></p>
    My problem is, when I add the Error object, I am getting below error when I submit the page
    java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!
    Can somebody help me, how to add validation on an annotated multiaction controller?