0
点赞
收藏
分享

微信扫一扫

加载自定义目录下的springmvc.xml配置文件 (2)


<servlet> 
<!-- 会根据<servlet-name>DispatcherServlet</servlet-name>中的DispatcherServlet去寻找WEB-INF下面的DispatcherServlet-servlet.xml文件 -->
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<!-- 加载自定义目录下的springmvc.xml配置文件 -->
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/springmvc.xml</param-value>
</init-param>
</servlet>

在src目录下新建config包,新建springmvc.xml文件,可以把DispatcherServlet-servlet.xml搬过来 ,如下


<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="

http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

">
<!-- 控制器 -->
<bean name="/hello.action" class="com.mo.springmvc.HelloAction"></bean>

<!-- 映射器(框架) -->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>

<!-- 适配器(框架) -->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean>

<!-- 视图解析器(框架) -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"></bean>

</beans>

举报

相关推荐

0 条评论