Spring MVC 出现 Did not find handler method for [uri] 可能的解决方法

在做SpringMVC 测试时发现在配置完全正确

0.相关JAR包完全导入,Tomcat启动完全成功

1.配置有扫描

 <!-- 处理静态资源 -->
    <mvc:default-servlet-handler/>
    <!--
    Configures the annotation-driven Spring MVC Controller programming model.
	Note that this tag works in Web MVC only, not in Portlet MVC!

	See org.springframework.web.servlet.config.annotation.EnableWebMvc javadoc for details
	on code-based alternatives to enabling annotation-driven Spring MVC support.
    -->
    <mvc:annotation-driven />
    <!-- 配置包扫描器,扫描@Controller注解的类 -->
    <context:component-scan base-package="com.taotao.controller.*"/>

2.在注解生效,且相应处理该次请求的Controller 已经被实例化(通过重写构造方法发现)

3.相关方法有RequestMapping注解(method字段与对应请求方式相符合)

    @RequestMapping(value = "/item/cat/list", method = {RequestMethod.POST})
    @ResponseBody
    public List<EasyUITreeNode> list(@RequestParam(value = "id", defaultValue = "0") long parentId) {
        System.out.println("进入了这个方法");
        return itemCatService.listCat(parentId);
    }

4. 相应控制器上看看有没有@RequestMapping 注解,有并在其中写上了相应uri路劲(如果你的控制器没有写上,而是写成了@Controller("/item/cat")  那么肯定是失败的,我就是心急没注意看到了这一步就解决了)

看看是不是


后端出现的错误:

2017-08-31 21:50:18,895 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'spring-mvc' processing GET request for [/item/cat/list]
2017-08-31 21:50:18,895 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /item/cat/list
2017-08-31 21:50:18,896 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/item/cat/list]
2017-08-31 21:50:18,896 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/item/cat/list] are [/**]
2017-08-31 21:50:18,896 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/item/cat/list] are {}
2017-08-31 21:50:18,896 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/item/cat/list] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler@1697861] and 1 interceptor
2017-08-31 21:50:18,896 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/item/cat/list] is: -1
2017-08-31 21:50:18,896 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'spring-mvc': assuming HandlerAdapter completed request handling
2017-08-31 21:50:18,896 [http-bio-8080-exec-3] DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request


页面出现的错误:

HTTP Status 404 - /item/cat/list

type Status report
message /item/cat/list
description The requested resource is not available.


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tienwj/article/details/77755836
个人分类: springmvc
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭