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. 《HTML5与CSS3基础教程》学习笔记 ——One Day

    第一章 1.    邮箱地址的URL地址包括:mailto:+邮箱地址 2.    ../表示向上走一级,开头直接使用/表示根目录 第三章 1.    <header>: role = “ ...

  2. AutoEventWireup="false"

    在 Web 服务器控件中,某些事件(通常是 Click 事件)会导致窗体被回发到服务器.HTML 服务器控件和 Web 服务器控件(如 TextBox 控件)中的更改事件将被捕获,但不会立即导致发送. ...

  3. 嵌入式系统图形库GUI核心模块介绍

    本文转载自:http://blog.csdn.net/xteda/article/details/6575278 (作者 冯青华 信庭嵌入式工作室(www.xteda.com)- CEO Blog:h ...

  4. c++11:function的用法

    function是函数.函数对象.函数指针.和成员函数的包装器,可以容纳任何类型的函数对象,函数指针,引用函数,成员函数的指针 普通函数 #include <functional> voi ...

  5. corosync+pacemaker实现高可用(HA)集群

    corosync+pacemaker实现高可用(HA)集群(一)     重要概念 在准备部署HA集群前,需要对其涉及的大量的概念有一个初步的了解,这样在实际部署配置时,才不至于不知所云 资源.服务与 ...

  6. ADO.NET笔记——带参数的查询防止SQL注入攻击

    相关知识: 把单引号替换成两个单引号,虽然能起到一定的防止SQL注入攻击的作用,但是更为有效的办法是把要拼接的内容做成“参数” SQLCommand支持带参数的查询,也就是说,可以在查询语句中指定参数 ...

  7. flex基础学习

    Flex是Adobe开发的一种RIA,富互联网应用,用Flex开发的东西都可以使用Flash做出来,但是Flex主要是面向的程序开发人员,前台使用ActionScript和MXML. 上面介绍了fle ...

  8. 京东sdk商家上架接口调用问题总结(更新中...)

    前言: 最近在做商家发布产品,调用京东sdk,发现问题很多,而且还是在我同事的帮助下完成的,摸索中,菜鸟还请高手门多多提携才好,入正题 首先是引用jd的sdk啦,京东sdk中发布商品需要调用一个 36 ...

  9. Game Tutorials

    SDL: http://www.sdltutorials.com/tutorials        http://lazyfoo.net/ http://panda3d.noie.name/ http ...

  10. mac os使用homebrew来管理后台服务

    在linux下我们经常通过 service 或者 /etc/init.d/来管理我们的后台服务软件,并使用包管理器安装这些软件. 在mac下有homebrew这个好用的工具来安装软件,但是一直没有找到 ...