当我使用modelAttribute =“ student”时,如何解决“ HTTP状态500 –内部服务器错误”

时间:2019-05-03 10:02:58

标签: spring model-view-controller

.java code and .jsp code are in the picture

绝对uri:[http://www.springframework.org/tags/form]不能在web.xml或与此应用程序一起部署的jar文件中解析

在图片中可以看到.java代码和.jsp代码。也许存在一些错误: form:form action =“ processForm” modelAttribute =“ student” 在学生表单中.jsp和 theModel.addAttribute(“ student”,theStudent); 在StudentController.java中

错误日志

at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:294)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:81)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:835)

2019年5月3日18:20:32.089 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet [dispatcher]中具有路径的Servlet.service() [/ ModelAttribute_demo_war_exploded]引发了异常[绝对uri:[{http://www.springframework.org/tags/form]无法在web.xml或与此应用程序一起部署的jar文件中解决]  org.apache.jasper.JasperException:绝对uri:[http://www.springframework.org/tags/form]无法在web.xml或与此应用程序一起部署的jar文件中解析     在org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)     在org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:294)     在org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:81)     在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)     在org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)     在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)     在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)     在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)     在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)     在org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:836)     在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1747)     在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)     在java.base / java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)     在java.base / java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:628)     在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     在java.base / java.lang.Thread.run(Thread.java:835)

1 个答案:

答案 0 :(得分:0)

替换您的

@RequestMapping ("/processForm")

与此:

@RequestMapping ("/processForm", method=RequestMethod.POST)

并分享输出/结果。

processForm选择的默认方法是GET,而不是POST。

更新

如果链接的帮助对您不利,请尝试添加学生进行建模。

public String processForm(@ModelAttribute ("student") Student theStudent, Model model)

model.addAttribute("student", theStudent);