3.web.xml配置文件
来源:互联网 发布:三剑客软件下载 编辑:程序博客网 时间:2024/06/16 10:07
注:如果web.xml没有提示信息,参考http://blog.csdn.net/qq_18570273/article/details/51009137
1.启动Spring容器,并配置Spring的地址
<!-- needed for ContextLoaderListener --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- Bootstraps the root web application context before servlet initialization --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
2.spring的前端控制器,拦截所有请求
注:可以不指定springmvc的位置,但是一定要在web.xml的同级目录下(也就是WEB-INF文件夹下),而且名字必须是 servlet-name加上“-servlet.xml”(我的名字是:dispathcherServlet-servlet.xml)
<!-- The front controller of this Spring Web application, responsible for handling all application requests --> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Map all requests to the DispatcherServlet for handling --> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
3.配置字符编码过滤器
<!-- 3.配置字符编码过滤器 --> <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> <init-param> <param-name>forceResponseEncoding</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>forceRequestEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
4.使用Rest风格的URI,将页面普通的post请求转化为指定的GET请求或者PUT请求
<filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
阅读全文
0 0
- 3.web.xml配置文件
- Webwork2 WEB.xml配置文件
- Tomcat 配置文件web.xml
- web.xml 配置文件详解
- web.xml 配置文件
- web.xml配置文件总结
- web.xml配置文件
- 配置文件web.xml小结
- Tomcat web.xml配置文件
- web.xml配置文件
- Tomcat web.xml配置文件
- j2ee web.xml配置文件
- 配置文件web.xml详解
- web.xml配置文件详解
- Web.xml 配置文件详解
- web.xml配置文件
- web.xml配置文件
- web.xml配置文件概述
- 常见注册
- 从零开始学习rocketmq(1)
- @Autowired写在成员变量上和set方法上的区别?
- ES6——Proxy(代理)、Reflect(反射)
- mybatis学习之路----bind的简单使用
- 3.web.xml配置文件
- 数据结构实验之栈与队列八:栈的基本操作
- 五分钟学GIS | 空间数据可视化渲染技术
- 5.leetCode:657. Judge Route Circle
- jdbctemplate方法在调用时 的相关配置以及注意事项
- 计算鼠标偏移量
- 算法学习-排序算法
- macOS系统下的文件夹加密
- Qt 学习之路 2(42):QListWidget、QTreeWidget 和 QTableWidget