Announcement Announcement Module
Collapse
No announcement yet.
Converter - An Errors/BindingResult argument is expected to be immediately Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converter - An Errors/BindingResult argument is expected to be immediately

    Hi

    I need help to deal with this exception:
    Code:
    java.lang.IllegalStateException: An Errors/BindingResult argument is expected to be immediately after the model attribute argument in the controller method signature: public java.lang.String com.###.GroupController.leaveGroup(com.###.UserGroup,org.springframework.validation.Errors,org.springframework.ui.Model)
    	at org.springframework.web.method.annotation.ErrorsMethodArgumentResolver.resolveArgument(ErrorsMethodArgumentResolver.java:61)
    	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:74)
    	at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:155)
    	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:117)
    	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
    I have an Erros parameter after my model so why is spring complaining ?
    My goal is to use a path variable to make a conversion to a bean.

    Here is the method of my controller
    Code:
    @RequestMapping("/group/{userGroupId:[0-9]+}/leave")
    public String leaveGroup(@PathVariable("userGroupId") UserGroup userGroup, Errors errors, Model model)
    The converter is configurer and works (I can see it in debug)
    Code:
    <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
    		<property name="converters">
    			<set>
    				<ref bean="userGroupConverter"/>
    			</set>
    		</property>
    	</bean>
    Regards

  • #2

    I have an Erros parameter after my model so why is spring complaining ?
    No you don't... You have an errors object after your PathVariable which is not a ModelAttribute!.

    Comment


    • #3
      @ModelAttribute

      What do you mean?
      Should I do something like this?


      Code:
      @RequestMapping("/group/{userGroupId:[0-9]+}/leave")
      public String leaveGroup(@PathVariable("userGroupId") @ModelAttribute UserGroup userGroup, Errors errors, Model model)
      Regards

      Comment


      • #4
        Errors or Binding can only follow a ModelAttribute (as explained in the reference guide) a converted path variable isn't a model attribute and as such there is no Errors object.

        There is no binding happening so there is no Errors / BindingResult.

        Why do you need it anyway if you don't do binding...

        Comment

        Working...
        X