SEVERE:servlet调度程序的Servlet.service()引发了异常 java.lang.IllegalStateException:BindingResult和bean名称'forum'的普通目标对象都不能作为请求属性使用 在org.springframework.web.servlet.support.BindStatus。(BindStatus.java:141) 在org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:175) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:195) 在org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:161) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:148) 在org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:139) 在org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:123) 在org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:380) 在org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140) 在org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:91) 在org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:78) at org.apache.jsp.WEB_002dINF.jsp.ForumList_jsp._jspx_meth_form_005finput_005f0(ForumList_jsp.java:189) at org.apache.jsp.WEB_002dINF.jsp.ForumList_jsp._jspx_meth_form_005fform_005f0(ForumList_jsp.java:138) 在org.apache.jsp.WEB_002dINF.jsp.ForumList_jsp._jspService(ForumList_jsp.java:94) 在org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 在org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) 在org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) 在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 在org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) 在org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) 在org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) 在org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:239) 在org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250) 在org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1062) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:709) 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:613) 在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:525) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) 在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) 在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:588) 在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489) 在java.lang.Thread.run(未知来源)
我无法在multiactioncontroller中绑定commandName becoz没有setCommandName和setCommandClass方法(methodSimpleFormController)
答案 0 :(得分:0)
如果您延长request.getParameter("parameterName");
,则只需MultiActionController
即可。使用setCommand()
扩展SimpleFormController
更新(有关getParameter()方法的更多理解):
假设你有一个这样的表格:
<form action="myController.html" method="post">
Name : <input type="text" name="username" value="${param.username}" />
<%--
That ${param.username} will help pre-populating the value
of the text field with `username` parameter
--%>
</form>
在您的控制器方法中,检索提交的参数,如:
public ModelAndView myControllerMethod(HttpServletRequest request, HttpServletResponse response) {
String username = request.getParameter("username");
}
如上所述,你不能使用扩展MultiActionController
的bean,你需要单独为所有bean属性执行它。