BindingResult和bean名称的纯目标对象都不能作为请求属性使用
我只是在学习Spring 3的注释fu的绳索,我偶然发现了newb的噩梦exception。 将不胜感激任何帮助。
这里是jsp代码的forms:
<form:form method="POST" action="login.htm" modelAttribute="login"> .... <form:input path="email" size="20" /> ....
控制器的代码(在这一点上,我只是简单的testing水域,所以不能直接指向任何页面,只是返回一个空string):
@Controller @SessionAttributes public class LoginController { @RequestMapping(value = "/login", method = RequestMethod.POST) public String login( @ModelAttribute("login") Login login, BindingResult result) { System.out.println( " email entered "+ login.getEmail()+ "\n" ); return "test"; }
“login”是一个具有适当的setter和getter的表单bean。
我认为我的调度程序servlet中的这一点代码应该照顾注释扫描:
<context:component-scan base-package="com.testAnnFu.controller" />
这是我尝试加载我的登陆jsp页面时抛出的可耻的exception。
SEVERE: Neither BindingResult nor plain target object for bean name 'login' available as request attribute java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'login' available as request attribute at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:147) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:138) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:122) at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:408) at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140) at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102) at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_input_0(landing_jsp.java from :208) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_form_0(landing_jsp.java from :164) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspService(landing_jsp.java from :107) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:787) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483) at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) WARNING: ApplicationDispatcher[/sssmgt] PWC1231: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'login' available as request attribute at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:147) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:138) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:122) at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:408) at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140) at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102) at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_input_0(landing_jsp.java from :208) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_form_0(landing_jsp.java from :164) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspService(landing_jsp.java from :107) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:787) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483) at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) WARNING: StandardWrapperValve[dispatcher]: PWC1406: Servlet.service() for servlet dispatcher threw exception java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'login' available as request attribute at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:147) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:138) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:122) at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:408) at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140) at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102) at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_input_0(landing_jsp.java from :208) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_form_0(landing_jsp.java from :164) at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspService(landing_jsp.java from :107) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:787) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483) at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454) at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680)
我敲开了窗体:input部分,并有一个纯粹的jsp页面,似乎加载。 只有当我介绍input是事情出错了。
我知道我的理解是如何将整个注释事件连接起来并映射到ModelAttribute,这是非常错误的。 我通过StOv的所有组合和postsearch了类似的例外情况,但我显然错过了一些东西。 有人能指点我的错误吗?
在控制器中,您需要添加login对象作为模型的一个属性:
model.addAttribute("login", new Login());
喜欢这个:
@RequestMapping(value = "/", method = RequestMethod.GET) public String displayLogin(Model model) { model.addAttribute("login", new Login()); return "login"; }
在http://localhost:8080/projectname/login
上执行GET
,您将会遇到此exception
由于Vinay已经正确地表明你可以肯定地使用
@RequestMapping(value = "/login", method = RequestMethod.GET) public String displayLogin(Model model) { model.addAttribute("login", new Login()); return "login"; }
但是我将提供一些我认为你正在使用Spring 3.0的替代语法。
你也可以用上面的function来实现
@RequestMapping(value = "/login", method = RequestMethod.GET) public String displayLogin(Login loginModel) { return "login"; }
和它login.jsp
(假设你正在使用InternalResourceViewResolver
),你可以有
<form:form method="POST" action="login.htm" modelAttribute="login">
注意 :modelAttribute是login
而不是loginModel
。 这是根据你在争论中提供的类名。 但是,如果要使用loginModel
作为modelAttribute是jsp,则可以执行以下操作
@RequestMapping(value = "/login", method = RequestMethod.GET) public String displayLogin(@ModelAttribute("loginModel")Login loginModel) { return "login"; }
和jsp会有
<form:form method="POST" action="login.htm" modelAttribute="loginModel">
我知道做同样的事情有不同的方法。 但是这里最重要的一点要注意 –
Imp注意 :当您在方法参数中添加模型类(如public String displayLogin(Login loginModel)
)时,它会自动创build并添加到您的Model对象中(这就是为什么您可以直接在JSP中访问它而无需手动将其放入模型)。 然后,它会search你的请求,如果请求有属性,它可以映射与新的ModelObject创build。 如果是的话,Spring会把请求参数中的值注入到你的自定义模型对象类(在这种情况下是Login)。
你可以通过做这个testing
@RequestMapping(value = "/login", method = RequestMethod.GET) public String displayLogin(Login loginModel, Model model) { System.out.println(model.asMap.get("login").equals(loginModel)); return "login"; }
注意 :如果给定了@SessionAttributes({"login"})
上面创build新的自定义模型对象可能不成立。 在这种情况下,它将从会话和填充值中获取。
我有这样的问题,但有几个“行动”。 我的解决scheme如下所示:
<form method="POST" th:object="${searchRequest}" action="searchRequest" > <input type="text" th:field="*{name}"/> <input type="submit" value="find" th:value="find" /> </form> ... <form method="POST" th:object="${commodity}" > <input type="text" th:field="*{description}"/> <input type="submit" value="add" /> </form> @Controller @RequestMapping("/goods") public class GoodsController { @RequestMapping(value = "add", method = GET) public String showGoodsForm(Model model){ model.addAttribute(new Commodity()); model.addAttribute("searchRequest", new SearchRequest()); return "goodsForm"; } @RequestMapping(value = "add", method = POST) public ModelAndView processAddCommodities( @Valid Commodity commodity, Errors errors) { if (errors.hasErrors()) { ModelAndView model = new ModelAndView("goodsForm"); model.addObject("searchRequest", new SearchRequest()); return model; } ModelAndView model = new ModelAndView("redirect:/goods/" + commodity.getName()); model.addObject(new Commodity()); model.addObject("searchRequest", new SearchRequest()); return model; } @RequestMapping(value="searchRequest", method=POST) public String processFindCommodity(SearchRequest commodity, Model model) { ... return "catalog"; }
我敢肯定 – 这里不是“最佳实践”,但它是没有“BindingResult也没有作为请求属性可用的bean名称的纯粹的目标对象”的作品。
只需添加
model.addAttribute("login", new Login());
你的方法..
它会工作..
当你第一次返回表单时,确保你传递了表单需要的模型 属性 ,可以通过添加下面的代码来完成
@RequestMapping(value = "/", method = RequestMethod.GET) public String login(Login login) return "test"; }
默认情况下,模型属性名称以第一个小写字母作为Bean类的名称
通过这样做,期望命名为“login”的支持对象的表单将可用
提交表单之后,可以通过传递bean对象和bindingresult作为方法参数进行validation,如下所示
@RequestMapping(value = "/login", method = RequestMethod.POST) public String login( @ModelAttribute("login") Login login, BindingResult result)
如果将Model或transfer对象传递给GET方法,但仍然存在此错误,请检查variables的命名。 在camelcase中使用实体/传送对象名称。 我有BusinessTripDTO对象,简称“旅行”。 它导致了这个错误,即使我有其他所有的部分。 在Java和Thymeleaf中将variables重命名为businessTripDTO,为我解决了这个问题。
我在IntelliJ IDEA有一个类似的问题。 我的代码是100%正确的,但启动Tomcat后,您会收到一个exception。 java.lang.IllegalStateException:既不BindingResult
我刚刚删除并添加了Tomcatconfiguration。 它为我工作。
图片Tomcatconfiguration