WEB开发网
开发学院软件开发Java spring 3.0 应用springmvc 构造RESTful URL 详细讲... 阅读

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/s

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> 

上一页  1 2 3 4 5  下一页

Tags:spring 应用 springmvc

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接