使用Spring MVC Portlet我需要在modelattribute中从依赖于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!
有什么想法吗?感谢您的帮助
答案 0 :(得分:0)
您已错误地声明了您的模型属性。 值不应该在那里。
public void editUser(@ModelAttribute("user") UserInfo user, BindingResult bindingResult,
ActionResponse response, SessionStatus sessionStatus, ActionRequest request)