spring 3.0 应用springmvc 构造RESTful URL 详细讲解
2009-09-21 00:00:00 来源:WEB开发网spring rest配置指南
1. springmvc web.xml配置
Xml代码
<!-- 该servlet为tomcat,jetty等容器提供,将静态资源映射从/改为/static/目录,如原来访问 http://localhost/foo.css ,现在http://localhost/static/foo.css -->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- URL重写filter,用于将访问静态资源http://localhost/foo.css 转为http://localhost/static/foo.css -->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>confReloadCheckInterval</param-name>
<param-value>60</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 覆盖default servlet的/, springmvc servlet将处理原来处理静态资源的映射 -->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 浏览器不支持put,delete等method,由该filter将/blog?_method=delete转换为标准的http delete方法 -->
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<servlet-name>springmvc</servlet-name>
</filter-mapping>
- ››Spring源码学习-含有通配符路径解析(上)
- ››应用云平台的可用性——从新浪SAE看云平台设计
- ››应用程序的配置管理Poco
- ››应用WebSphere MQ V6 来构建企业信息总线的行业示...
- ››应用 Python 解决一些实际问题
- ››应用JScript和XML自定义无刷新多级联动菜单
- ››Spring MVC与JAX-RS比较与分析
- ››应用:C/C++获取本机IP地址
- ››应用程序开发者偏好苹果也关注Android
- ››Spring 框架的设计理念与设计模式分析
- ››Spring Web Flow 2 中流管理的持久化
- ››Spring 事务管理高级应用难点剖析: 第 2 部分
更多精彩
赞助商链接