基本整合遇到的springmvc路径问题集合

2017-06-09  本文已影响0人  Kitlen

1./springMVC/view/spring/byebye.action

这种直接返回相关路径,二没有经过controller控制器的URL匹配

2.之前的不能进入控制器的错误,经过修改springmvc.xml文件后,可以进入了,要不老是提示找不到页面(黑体字那一部分就是提示已经可以进入jsp页面的href了,href就是到不了控制器)。但是就是找不到页面,后来springmvc.xml加入了一句。

ms

五月 29, 2017 10:56:39 上午 org.springframework.web.servlet.PageNotFound noHandlerFound

警告: No mapping found for HTTP request with URI [/springmvc5/helloworld] in DispatcherServlet with name 'springDispatcherServlet'

五月 29, 2017 11:00:37 上午 org.apache.catalina.core.StandardContext reload

信息: Reloading Context with name [/springmvc5] has started

五月 29, 2017 11:00:37 上午 org.apache.catalina.core.ApplicationContext log

信息: Destroying Spring FrameworkServlet 'springDispatcherServlet'

五月 29, 2017 11:00:37 上午 org.springframework.web.context.support.XmlWebApplicationContext doClose

信息: Closing WebApplicationContext for namespace 'springDispatcherServlet-servlet': startup date [Mon May 29 10:55:53 CST 2017]; root of context hierarchy

五月 29, 2017 11:00:38 上午 org.apache.catalina.startup.TldConfig execute

信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

五月 29, 2017 11:00:38 上午 org.apache.catalina.core.ApplicationContext log

信息: No Spring WebApplicationInitializer types detected on classpath

五月 29, 2017 11:00:38 上午 org.apache.catalina.core.ApplicationContext log

信息: Initializing Spring FrameworkServlet 'springDispatcherServlet'

五月 29, 2017 11:00:38 上午 org.springframework.web.servlet.DispatcherServlet initServletBean

信息: FrameworkServlet 'springDispatcherServlet': initialization started

五月 29, 2017 11:00:38 上午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh

信息: Refreshing WebApplicationContext for namespace 'springDispatcherServlet-servlet': startup date [Mon May 29 11:00:38 CST 2017]; root of context hierarchy

五月 29, 2017 11:00:38 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

信息: Loading XML bean definitions from class path resource [springmvc.xml]

五月 29, 2017 11:00:38 上午 org.springframework.web.servlet.DispatcherServlet initServletBean

信息:

修改之后如下图,其实<context:component-scan>配置之后,spring就可以自动去扫描base-package下及子包下的java文件,如果有扫描到@Component,@Controller,@Service等这些注解的类,就会把这些类注册为bean,添加的那句(图中蓝色条)只是降低扫描粒度,扫描指定包下的含有@Controller的java类(use-default-filter设置成false)。详见:http://www.cnblogs.com/youngjoy/p/3817471.html

正确配置后可以,进行访问

控制台信息输出:

五月 30, 2017 7:11:58 下午 org.apache.catalina.core.StandardContext reload

信息: Reloading Context with name [/springmvc6] has started

五月 30, 2017 7:11:58 下午 org.apache.catalina.core.ApplicationContext log

信息: Destroying Spring FrameworkServlet 'springDispatcherServlet'

五月 30, 2017 7:11:58 下午 org.springframework.web.context.support.XmlWebApplicationContext doClose

信息: Closing WebApplicationContext for namespace 'springDispatcherServlet-servlet': startup date [Tue May 30 19:09:47 CST 2017]; root of context hierarchy

五月 30, 2017 7:11:59 下午 org.apache.catalina.startup.TldConfig execute

信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

五月 30, 2017 7:11:59 下午 org.apache.catalina.core.ApplicationContext log

信息: No Spring WebApplicationInitializer types detected on classpath

五月 30, 2017 7:11:59 下午 org.apache.catalina.core.ApplicationContext log

信息: Initializing Spring FrameworkServlet 'springDispatcherServlet'

五月 30, 2017 7:11:59 下午 org.springframework.web.servlet.DispatcherServlet initServletBean

信息: FrameworkServlet 'springDispatcherServlet': initialization started

五月 30, 2017 7:11:59 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh

信息: Refreshing WebApplicationContext for namespace 'springDispatcherServlet-servlet': startup date [Tue May 30 19:11:59 CST 2017]; root of context hierarchy

五月 30, 2017 7:11:59 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

信息: Loading XML bean definitions from class path resource [springmvc.xml]

五月 30, 2017 7:12:00 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod

信息: Mapped "{[/helloworld],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.jackie.springmvc.handlers.HelloWorld.hello()

五月 30, 2017 7:12

3.还有个问题就是,就按照2正确配置之后,还是不行。之后重新命名项目再次运行就可以了。有可能是重命名操作让它扫描了一下依赖文件和重载了配置。关于Build project和clean选项,clean:相当于rebuild就是先删除工程中的.class文件,然后重新编译。项目修改了xml文件或者其他,先要clean一下,再运行才可以;如果只是jsp,则在tomcat下的clean就行。

3.1修改过的是页面直接运行就可看出修改过的效果。 如果是配置文件和类文件要重新启动服务器 才可以把修改过的内容显示出来(clean)反正clean是万能。

4.URL分大小写

上一篇下一篇

猜你喜欢

热点阅读