`
siashuayongsheng
  • 浏览: 118701 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

UrlRewrite

阅读更多
<filter>  
    <filter-name>UrlRewriteFilter</filter-name>  
    <filter-class>  
        org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>  
    <init-param>  
        <param-name>logLevel</param-name>  
        <param-value>WARN</param-value>  
    </init-param>  
</filter>  
<filter-mapping>  
    <filter-name>UrlRewriteFilter</filter-name>  
    <url-pattern>/*</url-pattern>  
</filter-mapping>  
   

   <filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>WARN</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


我用的是webwork
所有在webwork的过滤器配置文件那里需要加点东西
Java代码
<filter-mapping>  
    <filter-name>webwork</filter-name>  
    <url-pattern>/*</url-pattern>  
    <dispatcher>REQUEST</dispatcher>  
       <dispatcher>FORWARD</dispatcher>  
       <dispatcher>INCLUDE</dispatcher>  
</filter-mapping>  
   

  <filter-mapping>
<filter-name>webwork</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>


然后是在/WEB-INF/下面新建urlrewrite.xml
内容如下:
Java代码
  <?xml version="1.0" encoding="utf-8"?>  
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"  
        "http://tuckey.org/res/dtds/urlrewrite2.6.dtd">  
<urlrewrite>  
    <rule>  
        <from>^/register.jsp$</from>  
        <to>/register.action</to>  
    </rule>  
</urlrewrite>  
    

  <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
"http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
<urlrewrite>
<rule>
<from>^/register.jsp$</from>
<to>/register.action</to>
</rule>
</urlrewrite>


表示访问register.jsp的时候实际上访问的是register.action
下面是达人写的,参考
Java代码
   
<rule>  
        <note>homepage  blog username like http://blog.csdn.net/pigo</note>  
            <from>/u/([a-zA-Z0-9]+)/?$</from>  
            <to>/user/main.jsp?username=$1</to>  
        </rule>  
        <rule>  
        <note>homepage  blog username like http://blog.csdn.net/pigo/rss.xml</note>  
            <from>/u/([a-zA-Z0-9]+)/rss.xml$</from>  
            <to>/user/rss.jsp?username=$1</to>  
        </rule>  
        <rule>  
        <note> blog catgory  http://blog.csdn.net/pigo/category/42406.html</note>  
            <from>/u/([a-zA-Z0-9]+)/category/([a-zA-Z0-9]+).html</from>  
            <to>/user/cat.jsp?username=$1&catno=$2</to>  
        </rule>  
        <rule>  
        <note> blog catgory rss http://blog.csdn.net/pigo/category/42406.xml</note>  
            <from>/u/([a-zA-Z0-9]+)/category/([a-zA-Z0-9]+).xml</from>  
            <to>/user/catrss.jsp?username=$1&catno=$2</to>  
        </rule>  
         <rule>  
        <note> blog photo catgory  http://blog.csdn.net/pigo/photo/42406.html</note>  
            <from>/u/([a-zA-Z0-9]+)/photo/([a-zA-Z0-9]+).html</from>  
            <to>/user/photo.jsp?username=$1&catno=$2</to>  
        </rule>  
        <rule>  
        <note>blog issue http://blog.csdn.net/pigo/archive/2006/03/23/783904.html</note>  
            <from>/u/([a-zA-Z0-9]+)/archive/([0-9]+)/([0-9]+)/([0-9]+)/([a-zA-Z0-9]+).html</from>  
            <to>/user/issue.jsp?username=$1&blogno=$5</to>  
        </rule>  
        <rule>  
        <note>blogarchive by month http://blog.csdn.net/pigo/archive/2005/08.html </note>  
            <from>/u/([a-zA-Z0-9]+)/archive/([0-9]+)/([0-9]+).html</from>  
            <to>/user/archivelist.jsp?username=$1&year=$2&month=$3</to>  
        </rule>  
        <rule>  
        <note>blogapi by user http://blog.csdn.net/pigo/blogapi.html </note>  
            <from>/u/([a-zA-Z0-9]+)/blogapi.html</from>  
            <to>/blogapi/?username=$1</to>  
        </rule>  
         <rule>  
        <note>blogadmin by user http://blog.csdn.net/pigo/blogadmin.html </note>  
            <from>/u/([a-zA-Z0-9]+)/blogadmin.html</from>  
            <to>/admin/index.jsp?username=$1</to>  
        </rule> 

0 0 0
(请您对文章做出评价)
分享到:
评论

相关推荐

    URLRewrite配置和使用

    URLRewrite配置和使用 URLRewrite是一种URL重写技术,它可以满足搜索引擎的要求,隐藏技术实现,提高网站的移植性,并满足美感的要求。下面将详细介绍URLRewrite的配置和使用。 1. 满足搜索引擎的要求 搜索引擎对...

    netcn_URLRewrite

    什么是UrlRewrite UrlRewrite 是 将动态页面转换为静态页面的一种技术 例如 您网站页面是 http: www yourdomain com news docread aspx id 123 为什么使用UrlRewrite: 1 处理这样的情形:你要更改你的web应用...

    urlrewrite 支持自定义多配置文件

    在网上找了很多都不合心意,就知道改了下源码,只改了org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.class 文件,如果担心安全的朋友,可以下载 4.0.3的jar 替换UrlRewriteFilter.class即可。 confPath 默认 ...

    urlrewrite 支持自定义多配置文件(*通配符)

    urlrewrite 只支持单个配置文件,默认的配置文件为:/WEB-INF/urlrewrite.xml 现在对urlrewrite-3.2的源码进行了修改,使它能够支持多文件和通配符的形式加载自定义配置文件,即可以进行如下的配置: &lt;param-name&gt;...

    urlrewrite-maven-example.zip

    urlrewrite重写地址,Urlrewrite 2.5.2 现在有2.6版本的,自己去网上找吧

    URL Rewrite.zip

    URL Rewrite是微软针对IIS推出的一种对URL进行重写的扩展模块,目前支持用于IIS7及以上版本。该模块使IIS管理员能够创建强大的自定义规则,语法支持正则规则以及通配符规则过滤。它能够根据HTTP头和IIS服务器变量...

    打造UrlRewrite源码

    打造UrlRewrite源码 UrlRewrite一般都是在web.config里配置访问规则在路由到实际页面,所以先实现自定义节点信息读取,这里我定义了俩个类 webconfig定义了组,不需要的话可以把UrlRewriteConfigGroup类去掉并修改...

    UrlReWrite(Url重写或伪静态)

    UrlReWrite(Url重写或伪静态)UrlReWrite(Url重写或伪静态)

    IIS URL Rewrite模块(URL 重写).xmind

    IIS URL Rewrite模块(URL 重写)

    urlRewrite

    UrlRewrite就是我们通常说的地址重写,用户得到的全部都是经过处理后的URL地址 优点:安全,美化,搜索引擎SEO

    urlrewrite-3.1.0.jar

    urlrewrite Jar包 urlrewrite-3.1.0.jar

    UrlReWrite(Url重写或伪静态)完美示例源码

    描 述:UrlReWrite(Url重写或伪静态)完美示例源码 UrlReWrite(Url重写或伪静态)完美示例源码,已利用ActionlessForm解决原始地址form回传的问题 例如:/products.aspx?category=books 转换为/products/Books....

    UrlRewrite.rar

    UrlRewrite.rarUrlRewrite.rar

    UrlRewrite.dll

    UrlRewrite.dll 在使用开发的时候,win7或者win8的系统,可能会需要

    URLRewrite帮助文档

    URLRewrite使用时候一些属性的配置说明

    URLRewrite URL重写组件

    URLRewrite URL重写组件 里边有相关配置说明 包括了web.Config 外附一个Css

    urlrewrite 4.0.3 jar包.rar

    urlrewrite 4.0.3 jar

    URLrewrite-实例

    java urlrewrite demo

    IIS Urlrewrite2

    IIS Urlrewrite2,IIS服务器URl重写工具,,IIS服务器URl重写工具,,IIS服务器URl重写工具,

    Java高并发:静态页面生成方案--UrlRewrite

    UrlRewrite就是我们通常说的地址重写,用户得到的全部都是经过处理后的URL地址。 优点 一:提高安全性,可以有效的避免一些参数名、ID等完全暴露在用户面前,如果用户随便乱输的话,不符合规则的话直接会返回个404或错误...

Global site tag (gtag.js) - Google Analytics