0

使用 Spring MVC Portlet,我需要在模型属性中从依赖于 ActionRequest(liferay 6.1.1)的服务中检索信息。

我试过这个:

@ActionMapping(params="myaction=editUser")
    public void editUser(@ModelAttribute(value = "user") UserInfo user, BindingResult bindingResult,
                                        ActionResponse response, SessionStatus sessionStatus, ActionRequest request)
            throws Exception {

        myEditUserValidator.validate(user, bindingResult);

    //...
}

@ModelAttribute("user")
    public UserInfo getUser(@RequestParam String uid, ActionRequest request) throws Exception {
        return ldapService.getUser(uid, getVirtualPortalLdapMapping(request, virtualPortals));
}

但错误是:

ERROR [DispatcherPortlet:559] Could not complete request
org.springframework.web.bind.annotation.support.HandlerMethodInvocationException:
Failed to invoke handler method [public void com.mystuff.portlets.controllers.EditUserController.editUser(org.springframework.ui.Model,java.lang.String,org.springframework.validation.BindingResult,javax.portlet.ActionResponse,org.springframework.web.bind.support.SessionStatus,javax.portlet.ActionRequest)
throws java.lang.Exception]; nested exception is java.lang.IllegalStateException: 
Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!

任何想法?感谢您的任何帮助

4

1 回答 1

0

您错误地声明了模型属性。价值不应该在那里。

public void editUser(@ModelAttribute("user") UserInfo user, BindingResult bindingResult,
ActionResponse response, SessionStatus sessionStatus, ActionRequest request)
于 2013-08-06T09:11:25.370 回答