完整异常
org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:201) org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:420) org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:366) org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:66) org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:404) org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1233) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1016) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) com.github.xiaoymin.swaggerbootstrapui.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:84) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) com.github.xiaoymin.swaggerbootstrapui.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
首先看异常信息,,,直接看第一行,,,大概说的是【请求映射信息处理器映射】中的【handle没有匹配】错误,,,
接着直接定位到错误类的错误方法,就是下面这个 👇👇👇,,,
1 protected HandlerMethod handleNoMatch(Set<RequestMappingInfo> infos, String lookupPath, HttpServletRequest request) throws ServletException { 2 RequestMappingInfoHandlerMapping.PartialMatchHelper helper = new RequestMappingInfoHandlerMapping.PartialMatchHelper(infos, request); 3 if (helper.isEmpty()) { 4 return null; 5 } else { 6 Set mediaTypes; 7 if (helper.hasMethodsMismatch()) { 8 mediaTypes = helper.getAllowedMethods(); 9 if (HttpMethod.OPTIONS.matches(request.getMethod())) { 10 RequestMappingInfoHandlerMapping.HttpOptionsHandler handler = new RequestMappingInfoHandlerMapping.HttpOptionsHandler(mediaTypes); 11 return new HandlerMethod(handler, HTTP_OPTIONS_HANDLE_METHOD); 12 } else { 13 throw new HttpRequestMethodNotSupportedException(request.getMethod(), mediaTypes); 14 } 15 } else if (helper.hasConsumesMismatch()) { 16 mediaTypes = helper.getConsumableMediaTypes(); 17 MediaType contentType = null; 18 if (StringUtils.hasLength(request.getContentType())) { 19 try { 20 contentType = MediaType.parseMediaType(request.getContentType()); 21 } catch (InvalidMediaTypeException var8) { 22 throw new HttpMediaTypeNotSupportedException(var8.getMessage()); 23 } 24 } 25 26 throw new HttpMediaTypeNotSupportedException(contentType, new ArrayList(mediaTypes)); 27 } else if (helper.hasProducesMismatch()) { 28 mediaTypes = helper.getProducibleMediaTypes(); 29 throw new HttpMediaTypeNotAcceptableException(new ArrayList(mediaTypes)); 30 } else if (helper.hasParamsMismatch()) { 31 List<String[]> conditions = helper.getParamConditions(); 32 throw new UnsatisfiedServletRequestParameterException(conditions, request.getParameterMap()); 33 } else { 34 return null; 35 } 36 } 37 }
接着跟着调试,会发现问题是第9行代码出现了问题,13行抛出的该异常,也就是
if (HttpMethod.OPTIONS.matches(request.getMethod())) { RequestMappingInfoHandlerMapping.HttpOptionsHandler handler = new RequestMappingInfoHandlerMapping.HttpOptionsHandler(mediaTypes); return new HandlerMethod(handler,HTTP_OPTIONS_HANDLE_METHOD); } else { throw new HttpRequestMethodNotSupportedException(request.getMethod(), mediaTypes);
}
结论:
调试就会发现是 【OPTIONS】匹配不上【POST】方法,这样就让我不由得看了看自己方法的方法请求方式,,,
一看真是【GET】,改的和前端一样就好了...
所以前后端分离项目中,,,猴子们的沟通真的很重要啊,,,
像我就是不知道前端什么时候"偷偷"改成了post = =