接手的一个项目用了SpringMVC 现在我直接用Servlet报如下错,是什么原因,怎么解决

时间:2023-01-21 15:36:17
16:10:09.703 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[JeeCmsFront] - Servlet.service() for servlet JeeCmsFront threw exception
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:623) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) [servlet-api.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:659) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:457) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395) [catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) [catalina.jar:na]
at com.tps.servlet.ApplyServlet.doPost(ApplyServlet.java:76) [ApplyServlet.class:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) [servlet-api.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) [catalina.jar:na]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) [catalina.jar:na]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) [catalina.jar:na]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [catalina.jar:na]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) [catalina.jar:na]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) [catalina.jar:na]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) [catalina.jar:na]
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:843) [tomcat-http.jar:na]
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:679) [tomcat-http.jar:na]
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1293) [tomcat-util.jar:5.1]
at java.lang.Thread.run(Unknown Source) [na:1.5.0_11]
16:10:09.703 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[apply] - Servlet.service() for servlet apply threw exception
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:623) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) ~[servlet-api.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) ~[catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) ~[catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:659) ~[catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:457) ~[catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395) ~[catalina.jar:na]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) ~[catalina.jar:na]
at com.tps.servlet.ApplyServlet.doPost(ApplyServlet.java:76) ~[ApplyServlet.class:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) ~[servlet-api.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) ~[catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) ~[catalina.jar:na]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) ~[catalina.jar:na]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) [catalina.jar:na]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [catalina.jar:na]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) [catalina.jar:na]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) [catalina.jar:na]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) [catalina.jar:na]
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:843) [tomcat-http.jar:na]
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:679) [tomcat-http.jar:na]
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1293) [tomcat-util.jar:5.1]
at java.lang.Thread.run(Unknown Source) [na:1.5.0_11]

4 个解决方案

#1


请求都会被DispatcherServlet拦截,你直接用Servlet,当然无法派发请求。

#2


报错信息为该请求不支持post形式,你是不是配置了requestmethod为get或put等,如果配置了,就只能接收那种请求。
如果你想用表单提交,也必须设置type=get而不是post

#3


高手过招,我路过

#4


看看@RequestMapping的参数是POST,还是GET

#1


请求都会被DispatcherServlet拦截,你直接用Servlet,当然无法派发请求。

#2


报错信息为该请求不支持post形式,你是不是配置了requestmethod为get或put等,如果配置了,就只能接收那种请求。
如果你想用表单提交,也必须设置type=get而不是post

#3


高手过招,我路过

#4


看看@RequestMapping的参数是POST,还是GET