未来IT
2016-12-07 16:35
怎么设置spring随tomcat启动开始加载xml
谢谢~~~~
1.web.xml中增加
<servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
2.同级目录增加spring配置文件,注意文件命名规则:servlet-name+“-servlet.xml”如:
mvc-dispatcher-servlet.xml
或
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/mvc-context.xml</param-value> </context-param>
Spring入门篇
268787 学习 · 963 问题
相似问题