1.jar包支持urlrewritefilter-4.0.3.jar  http://files.cnblogs.com/simpledev/urlrewritefilter-4.0.3.rar

2.在web.xml文件中加入:

<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>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

3.在项目的WEB-INF/文件夹下面加入:urlrewrite.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd"> <!-- Configuration file for UrlRewriteFilter
http://www.tuckey.org/urlrewrite/ -->
<urlrewrite> <rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/test/status/</from>
<to type="redirect">%{context-path}/rewrite-status</to>
</rule> <outbound-rule>
<note>
The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/. The above rule and this outbound-rule means that end users should never see the
url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
in your pages.
</note>
<from>/rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>
<!-- 养车互动 -->
<rule>
<from>/hudong.html</from>
<to>/hudong.jsp</to>
</rule>
<rule>
<from>/hudong/article/(\d+).html</from>
<to>/careArticleAction?actionName=detail&amp;id=$1</to>
</rule>
<rule>
<from>/hudong/article/(\d+)-(\d+).html</from>
<to>/careArticleAction?actionName=detail&amp;id=$1&amp;pageId=$2</to>
</rule>
<rule>
<from>/hudong/listArticle.html</from>
<to>/careArticleAction?actionName=listArticle</to>
</rule>
<rule>
<from>/hudong/listArticle-(\d+).html</from>
<to>/careArticleAction?actionName=listArticle&amp;pageId=$1</to>
</rule>
</urlrewrite>

注意:变量用$1,$2,$3等来取代,数字(\d+),字母(\w+)正则表达式来表达。
&符号一定要写成: &amp;否则xml文件加载失败~!!!

.   匹配除换行符以外的任意字符
/w   匹配字母或数字或下划线或汉字
/s  匹配任意的空白符
/d  匹配数字
/b  匹配单词的开始或结束
^  匹配字符串的开始
$  匹 配字符串的结束

项目启动之后:如访问http://localhost:8080/BNCAR2/rewrite-status 如果xml文件没有错误,会显示正常,否则会提示错误位置信息等。

以上链接伪静态代表的含义为:

访问http://localhost:8080/BNCAR2/hudong.html 代替http://localhost:8080/BNCAR2/hudong.jsp

访问http://localhost:8080/BNCAR2/hudong/article/100.html 代替http://localhost:8080/BNCAR2/careArticleAction?actionName=detail&id=100

访问http://localhost:8080/BNCAR2/hudong/article/100-1.html 代替http://localhost:8080/BNCAR2/careArticleAction?actionName=detail&id=100&pageId=1

访问http://localhost:8080/BNCAR2/hudong/listArticle.html 代替http://localhost:8080/BNCAR2/careArticleAction?actionName=listArticle

java 伪静态的方法的更多相关文章

  1. oracle调用JAVA类的方法

    导入jar包 在oracle中导入需要的jar包,我们把编辑好的java类打成jar包,直接在oarcle里面写简单的调用就可以了,  1.操作系统需要拥有支持loadjava命令的jdk.  2.加 ...

  2. YII 伪静态 IIS7 方法 web.config

    YII 伪静态 IIS7 方法 web.config <?xml version="1.0" encoding="UTF-8"?> <conf ...

  3. Java中的方法应用

    一.如何定义java中的方法 所谓方法,就是用来解决一类问题的代码的有序组合,是一个功能模块. 语法: 1. 访问修饰符:方法允许被访问的权限范围, 可以是 public.protected.priv ...

  4. ASP.NET伪静态的方法及相关资料

    1. 添加URLRewriter.dll引用 2. 配置web.config的基本信息 <configSections> <section name="RewriterCo ...

  5. Java Runtime.availableProcessors()方法

    Java Runtime.availableProcessors()方法用法实例教程.   描述 java.lang.Runtime.availableProcessors() 方法返回到Java虚拟 ...

  6. paip.java OutOfMemoryError 解决方法o33

    paip.java OutOfMemoryError 解决方法o33 java.lang.OutOfMemoryError: Requested # java.lang.OutOfMemoryErro ...

  7. Java读写文件方法总结

    Java读写文件方法总结 Java的读写文件方法在工作中相信有很多的用处的,本人在之前包括现在都在使用Java的读写文件方法来处理数据方面的输入输出,确实很方便.奈何我的记性实在是叫人着急,很多时候既 ...

  8. java调用本地方法的时候报错 could not find the main class:xx.program will exit

    如图所示,当在java调用本地方法的时候报错 我的解决办法是把dll文件放到System.out.println(System.getProperty("java.library.path& ...

  9. 给NSString增加Java风格的方法

    给NSString增加Java风格的方法 文章目录 我实在受不了 NSString 冗长的方法调用了,每次写之前都要查文档.特别是那个去掉前后多余的空格的方法,长得离谱.与之对应的别的语言,拿 jav ...

随机推荐

  1. 分享web前端七款HTML5 Loading动画特效集锦

    以前我们大部分的Loading动画都是利用gif图片实现的,这种图片实现Loading动画的方法虽然也很不错,但是作为HTML5开发者来说,如果能利用HTML5和CSS3实现这些超酷的Loading动 ...

  2. Codevs 1014 装箱问题

    题目描述 Description 有一个箱子容量为V(正整数,0<=V<=20000),同时有n个物品(0<n<=30),每个物品有一个体积(正整数). 要求n个物品中,任取若 ...

  3. c语言 char*类型作为中间变量将许多字符串保存到一个数组的问题

    char*是一个字符串指针,如下面的程序value_作为一个中间变量用来在for循环中scanf输入的值的接收者,然后将value_保存到array中,但是一下程序会出现一个问题就是当你跳出这个函数时 ...

  4. 标签控制器,UITabBarController

    注意: 1.tabbar高度不可设置,可通过_tabbar.tabbar.frame设置tabbar的位置 2.tabbar不同页面添加同一个视图后其那面添加的不起作用,只有最后一个才具有所添加的仕途 ...

  5. linux下别名alias的设置

    我有一个常用目录/volumes/mac/www’,每次都要输入这么长的路径,麻烦,所以有了以下配置 1.vi ~/.bash_profile 2.按住shift + i进入编辑状态 3.插入 ali ...

  6. Android listview viewpager解决冲突 滑动

    Android listview viewpager滑动 跳动 冲突解决 ListView中嵌套ViewPage有或者滑动手势冲突解决   在listview 上使用 addHeaderView 在第 ...

  7. Dll学习一_Dll 创建并动态引用窗体且释放窗体Demo

    1.新建Dll工程 2.Dll工程全部代码 library SubMain; { Important note about DLL memory management: ShareMem must b ...

  8. Linux挂载60T存储

    操作系统: CentOS 6.3 存储:总大小为72T,并划分成3个块,每块20T 安装多实例MySQL数据库,不想挂载3个块,弄成一个大的比较方便管理,个人比较懒. 配置多路径:http://blo ...

  9. JVM基础:深入学习JVM堆与JVM栈

    转自:http://developer.51cto.com/art/201009/227812.htm JVM栈解决程序的运行问题,即程序如何执行,或者说如何处理数据;JVM堆解决的是数据存储的问题, ...

  10. VBS基础篇 - 常量

    常量:指的是在程序运行过程中其值保持不变的量,它用来保存固定不变的数值,字符串等常数 . 常量的定义:在vbscript中使用使用 Const 指令可以创建名称具有一定含义的字符串型或数值型常量,并给 ...