ssm整合基本配置之web.xml
2017-12-26 16:36
471 查看
个人理解+参考总结,有错误请提出,谢谢!
1、加载spring配置文件:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
</param-value>
</context-param>
2、配置ContextLoaderListener:
ContextLoaderListener的作用就是启动Web容器时,自动装配ApplicationContext的配置信息。
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
参考:http://wenwen.sogou.com/z/q740178826.htm
3、配置DispatcherServlet:
DispatcherServlet主要负责流程的控制。
<!-- spring mvc核心:分发servlet(就是控制流程) -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<!-- spring mvc的配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- 如是在WEB-INF文件夹下 如下这样写
<param-value>/WEB-INF/springmvc.xml</param-value> -->
<!-- 如果实在src文件夹下 如下这样写
<param-value>classpath:springMVC.xml</param-value>-->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
参考:http://jinnianshilongnian.iteye.com/blog/1602617
4、配置中文乱码处理CharacterEncodingFilter:
<filter>
<filter-name>encodingFilter</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>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
1、加载spring配置文件:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
</param-value>
</context-param>
2、配置ContextLoaderListener:
ContextLoaderListener的作用就是启动Web容器时,自动装配ApplicationContext的配置信息。
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
参考:http://wenwen.sogou.com/z/q740178826.htm
3、配置DispatcherServlet:
DispatcherServlet主要负责流程的控制。
<!-- spring mvc核心:分发servlet(就是控制流程) -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<!-- spring mvc的配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- 如是在WEB-INF文件夹下 如下这样写
<param-value>/WEB-INF/springmvc.xml</param-value> -->
<!-- 如果实在src文件夹下 如下这样写
<param-value>classpath:springMVC.xml</param-value>-->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
参考:http://jinnianshilongnian.iteye.com/blog/1602617
4、配置中文乱码处理CharacterEncodingFilter:
<filter>
<filter-name>encodingFilter</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>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
相关文章推荐
- 【SSM整合】-三框架整合xml文件结构及相应web.xml配置
- 使用ssm框架在web.xml中的基本配置信息
- SSM整合之web.xml的相关配置
- Spring整合Structs2 的web.xml 基本配置
- SSM(spring-springmvc-mybatis)整合开发xml配置文件内容springmvc-config.xml,application.xml,web.xml
- ssm框架整合配置---web.xml,傻傻分不清楚
- jsp web.xml文件的作用及基本配置
- WEB.XML的一些基本配置
- 整合struts1时web.xml里的配置
- ssm框架整合的配置文件applicationContext.xml
- struts2在web.xml中的基本配置
- JSP中web.xml文件的作用及基本配置
- web.xml文件的作用及基本配置
- web.xml文件的作用和基本配置
- ssm整合_XML常规配置
- web.xml基本配置
- JFinal 项目web.xml 基本配置解读 项目
- CXF之用spring整合web项目时, web.xml配置实例
- SpringMVC之web.xml基本配置
- jsp web.xml文件的作用及基本配置