Announcement Announcement Module
Collapse
No announcement yet.
Adding validation on an annotated multiactioncontroller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.

    Code:
    @RequestMapping("/validateQualItem.htm")
    	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.

    Code:
    <form name="qa-form-182" action="validateQualItem.htm" method="post">
    	<p>
    		<label for="qaRemarks" class="label">QA Remarks:</label>
    		<textarea  rows="5" cols="23" id="qa-remarks"></textarea>
    	</p>
    	<input type="hidden" value="23" name="lngTRN" />
    	<p><input class="action-button" type="submit" value="Validate" name="validate"/></p>
    </form>
    My problem is, when I add the Error object, I am getting below error when I submit the page
    Code:
    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?
Working...
X