web.xml配置
来源:互联网 发布:程序员穿正装 编辑:程序博客网 时间:2024/06/15 02:59
<!-- 加载Spring容器配置 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 设置Spring容器加载配置文件路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<!-- 配置Spring核心控制器 -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 解决工程编码过滤器 -->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3、 在WEB-INF目录中添加dispatcher.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"
<!-- 注解探测器 -->
<context:component-scan base-package="com.hoo"/>
<!-- annotation默认的方法映射适配器 -->
<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
</beans>
0 0
- log4j.xml web.xml配置
- web工程web.xml配置
- Web.XML 配置详解
- Web.XML 配置详解
- Web.Xml的配置
- web.xml配置说明
- web.xml配置详解
- web.xml配置详解
- Struts2 web.xml配置
- Tomcat web.xml配置
- tomcat web.xml配置
- web.xml配置说明
- web.xml详细配置
- web.xml配置讲解
- web.xml配置详解
- SSH配置:web.xml
- Web.XML 配置详解
- web.xml中的配置
- Zookeeper 的学习与运用
- CSDN学院讲师招募,诚邀您加入!
- 设置listview 中每个Item之间的间距
- JS:json对象和字符串之间的转换。
- 国产手机逆袭考验核心竞争力
- web.xml配置
- android Thread+handler 实现UI更新
- bjfuOJ 1017组合的字典序(模拟求直接后继,分情况讨论)
- java数据库连接池
- windows驱动编程学习笔记——(一)
- 定制iOS 7中的导航栏和状态栏(转)
- SAFS/STAF/STAX自动化测试框架
- 【Java并发编程】之二:线程中断(含代码)
- Android DOM解析XML方法及优化