springmvc发生No mapping found for HTTP request with URI[…] in dispatcher servlet

Java 发表评论

今天做springmvc注解的demo,怎么搞都会报No mapping found for HTTP request with URI[…] in dispatcherservlet,而且console中并没有出现Mapped信息。

 

最后发现

         <!–Action,让springioc容器去扫描带@Controller的包中的类 –>

         <context:component-scanbase-package=”d_anno”/>

         <mvc:annotation-driven/>

是base-package,而我每次都设置了class,晕倒。设置好后,console中出现

四月 11, 2017 9:01:04 上午 org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
信息: Mapped "{[/d_anno/bye.action],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String d_anno.ByeAction.byeMethod(org.springframework.ui.Model) throws java.lang.Exception
四月 11, 2017 9:01:04 上午 org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
信息: Mapped "{[/d_anno/hello.action],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String d_anno.ByeAction.hello(org.springframework.ui.Model) throws java.lang.Exception
四月 11, 2017 9:01:04 上午 org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
信息: Mapped "{[/springmvcDemo/hello],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String d_anno.HelloAction.helloMethod(org.springframework.ui.Model) throws java.lang.Exception
四月 11, 2017 9:01:05 上午 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
信息: Mapped URL path [/d_anno/bye.action] onto handler 'byeAction'
四月 11, 2017 9:01:05 上午 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
信息: Mapped URL path [/d_anno/hello.action] onto handler 'byeAction'
四月 11, 2017 9:01:05 上午 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
信息: Mapped URL path [/springmvcDemo/hello] onto handler 'helloAction'
四月 11, 2017 9:01:05 上午 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
信息: Mapped URL path [/springmvcDemo/hello.*] onto handler 'helloAction'
四月 11, 2017 9:01:05 上午 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
信息: Mapped URL path [/springmvcDemo/hello/] onto handler 'helloAction'

以后还是要更细心。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

昵称 *