org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException

简介: NoSuchRequestHandlingMethodException
相信很多的朋友在开发过程中都或多或少的遇见一些异常,下面我给大家说一说NoSuchRequestHandlingMethodException

这个异常说的是找不到处理这样的请求方法,那是什么原因导致的:

下面我来说说我的在项目中遇见的,上线的项目运行了两周,查看日志记录,就出现了一个异常信息:

[ERROR] [2018-10-18 01:41:28] com.shou6.utils.exception.ExceptionHandler.resolveException(54) | Spring异常捕获顶层
org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException: No matching handler method found for servlet request: path '/server.do', method 'GET', parameters map[[empty]]
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:679)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:441)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.shou6.filter.RequestAttributeFilter.doFilter(RequestAttributeFilter.java:28)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:676)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

经过排查发现请求的url-server.do后面没有跟参数导致的,于是做了如下操作:

在filter中加判断


if ("".equals(request.getParameter("method")) || request.getParameter("method") == null) {
            //            return json4Map(jsonMap, null, "请求参数错误 ", STATUSCODE_FAILED_SERVER);
            response.getWriter().write("Request parameter error");
            return;
        }

这样就不会报错了。


相关文章
|
17天前
|
存储 Java Spring
深入理解org.springframework.web.context.request.RequestContextHolder
`RequestContextHolder`是Spring提供的一个便捷工具类,用于在非Controller层访问请求上下文信息。通过理解其工作原理和应用场景,可以更好地在Spring应用中管理和使用请求信息,提升代码的可维护性和扩展性。
53 0
|
5月前
|
监控 前端开发 Java
深入理解 org.springframework.web.servlet.AsyncHandlerInterceptor
深入理解 org.springframework.web.servlet.AsyncHandlerInterceptor
|
6月前
|
前端开发 Java 应用服务中间件
【JavaEE进阶】 初识Spring Web MVC
【JavaEE进阶】 初识Spring Web MVC
解决:org.springframework.web.method.annotation.MethodArgumentTypeMismatchExceptio
解决:org.springframework.web.method.annotation.MethodArgumentTypeMismatchExceptio
465 0
|
Java
【SpringBoot】WebMvcConfigurer实现类不被加载(o.s.web.servlet.PageNotFound : No mapping for GET)的问题解决
【SpringBoot】WebMvcConfigurer实现类不被加载(o.s.web.servlet.PageNotFound : No mapping for GET)的问题解决
1058 0
|
Java Spring Maven
【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
今天搭建新的项目,虽然在web.xml中配置了ContextLoaderListener以及IntrospectorCleanupListener 如下: web.xml中部分代码: 1 2 3 org.
2504 0
|
Web App开发 Java Apache
Spring Boot Web jsp 404
Spring Boot Web 项目添加 jsp 支持, pom.xml 必须添加 Tomcat 依赖 否则启动时输出中显示 map 成功了, 但是访问的时候会出现 404 错误。
2486 0
|
Web App开发 Java 数据格式
Spring项目的配置文件们(web.xml context servlet springmvc)
我们的spring项目目前用到的配置文件包括1--web.xml文件,这是java的web项目都必须有的,我理解它是servlet的配置文件,也就是说,与spring无关。即使你开发的是一个纯粹jsp页面的web项目,你也必须配置这个文件。
4789 0
|
Java 数据格式 容器
org.springframework.web.context.ContextLoaderListener
在web.xml里面会配置一个listener和一个dispatcher
4829 0