Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1960987
  • 博文数量: 606
  • 博客积分: 9991
  • 博客等级: 中将
  • 技术积分: 5725
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-17 19:07
文章分类

全部博文(606)

文章存档

2011年(10)

2010年(67)

2009年(155)

2008年(386)

分类: Java

2009-12-11 15:07:08

1、下载:
下载地址为urlrewrite/#download
2、配置

在struts的filter-mapping中加入以下就可以了

Xml代码 复制代码
  1. <filter-mapping>   
  2.         <filter-name>struts2 filter-name>   
  3.         <url-pattern>*.do url-pattern>   
  4.         <dispatcher>REQUEST dispatcher>     
  5.         <dispatcher>FORWARD dispatcher>     
  6.        <dispatcher>INCLUDE dispatcher>     
  7. filter-mapping>  

如下:

Xml代码 复制代码
  1.   
  2.     <filter>  
  3.         <filter-name>encodingFilterfilter-name>  
  4.         <filter-class>  
  5.              org.springframework.web.filter.CharacterEncodingFilter   
  6.         filter-class>  
  7.         <init-param>  
  8.             <param-name>encodingparam-name>  
  9.             <param-value>UTF-8param-value>  
  10.         init-param>  
  11.     filter>  
  12.       
  13.     <filter>  
  14.         <filter-name>osivFilterfilter-name>  
  15.         <filter-class>  
  16.              org.springframework.orm.hibernate3.support.OpenSessionInViewFilter   
  17.         filter-class>  
  18.     filter>  
  19.       
  20.     <filter>  
  21.         <filter-name>UrlRewriteFilterfilter-name>  
  22.         <filter-class>  
  23.              org.tuckey.web.filters.urlrewrite.UrlRewriteFilter   
  24.         filter-class>  
  25.         <init-param>  
  26.             <param-name>logLevelparam-name>  
  27.             <param-value>WARNparam-value>  
  28.         init-param>  
  29.     filter>  
  30.           
  31.     <filter>  
  32.         <filter-name>struts2-cleanupfilter-name>  
  33.         <filter-class>  
  34.              org.apache.struts2.dispatcher.ActionContextCleanUp   
  35.         filter-class>  
  36.     filter>  
  37.         <filter>  
  38.         <filter-name>struts2filter-name>  
  39.         <filter-class>  
  40.              org.apache.struts2.dispatcher.FilterDispatcher   
  41.         filter-class>  
  42.     filter>  
  43.     <filter-mapping>  
  44.         <filter-name>encodingFilterfilter-name>  
  45.         <url-pattern>/*url-pattern>  
  46.     filter-mapping>  
  47.   
  48.        
  49.     <filter-mapping>  
  50.         <filter-name>osivFilterfilter-name>  
  51.         <url-pattern>/*url-pattern>  
  52.     filter-mapping>  
  53.   
  54.     <filter-mapping>  
  55.         <filter-name>UrlRewriteFilterfilter-name>  
  56.         <url-pattern>/*url-pattern>  
  57.         <dispatcher>REQUESTdispatcher>  
  58.         <dispatcher>FORWARDdispatcher>  
  59.     filter-mapping>  
  60.   
  61.   
  62.     <filter-mapping>  
  63.         <filter-name>struts2-cleanupfilter-name>  
  64.         <url-pattern>/*url-pattern>  
  65.         <dispatcher>REQUESTdispatcher>     
  66.         <dispatcher>FORWARDdispatcher>   
  67.     filter-mapping>  
  68.   
  69.     <filter-mapping>  
  70.         <filter-name>struts2 filter-name>   
  71.         <url-pattern>/*url-pattern>   
  72.         <dispatcher>REQUESTdispatcher>     
  73.         <dispatcher>FORWARDdispatcher>   
  74.     filter-mapping>  

引用部分

1、在web.xml中EncodingFilter的位置应该在Struts2的FilterDispatcher之前,道理很简单,要先调整字符集,再进入Action。

2、如果使用Urlrewrite,要指定filter-mapping的dispatcher方式,如下

    Struts2
    /*
    REQUEST
    FORWARD


3、在做上传文件的时候,要在web.xml中增加ActionContextCleanUp这个filter,如果不增加,会发生第一次上传取不到文件的情况

struts-cleanup
org.apache.struts2.dispatcher.ActionContextCleanUp


    struts-cleanup
    /*

按照Struts2的API,filter的顺序是
struts-cleanup filter
SiteMesh filter
FilterDispatcher

相关链接:

阅读(2106) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~