0
Spring MVC Portlet我需要在modelattribute中從依賴於ActionRequest(liferay 6.1.1)的服務中檢索信息。@ModelAttribute依賴於ActionRequest
我已經試過這樣:
@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!
任何想法?感謝您的幫助
你的調用者希望你的方法有6個參數:Model,String,BindingResult,ActionResponse,SessionStatus和ActionRequest。而你的方法聲明只有5個參數:UserInfo user,BindingResult bindingResult,ActionResponse響應,SessionStatus sessionStatus,ActionRequest請求。 你可以粘貼你的UserInfo類嗎? –
謝謝,這是原因(我正在尋找一箇舊的錯誤...) – Paolof76