java 伪静态的方法
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&id=$1</to>
</rule>
<rule>
<from>/hudong/article/(\d+)-(\d+).html</from>
<to>/careArticleAction?actionName=detail&id=$1&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&pageId=$1</to>
</rule>
</urlrewrite>
注意:变量用$1,$2,$3等来取代,数字(\d+),字母(\w+)正则表达式来表达。
&符号一定要写成: &否则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 伪静态的方法的更多相关文章
- oracle调用JAVA类的方法
导入jar包 在oracle中导入需要的jar包,我们把编辑好的java类打成jar包,直接在oarcle里面写简单的调用就可以了, 1.操作系统需要拥有支持loadjava命令的jdk. 2.加 ...
- YII 伪静态 IIS7 方法 web.config
YII 伪静态 IIS7 方法 web.config <?xml version="1.0" encoding="UTF-8"?> <conf ...
- Java中的方法应用
一.如何定义java中的方法 所谓方法,就是用来解决一类问题的代码的有序组合,是一个功能模块. 语法: 1. 访问修饰符:方法允许被访问的权限范围, 可以是 public.protected.priv ...
- ASP.NET伪静态的方法及相关资料
1. 添加URLRewriter.dll引用 2. 配置web.config的基本信息 <configSections> <section name="RewriterCo ...
- Java Runtime.availableProcessors()方法
Java Runtime.availableProcessors()方法用法实例教程. 描述 java.lang.Runtime.availableProcessors() 方法返回到Java虚拟 ...
- paip.java OutOfMemoryError 解决方法o33
paip.java OutOfMemoryError 解决方法o33 java.lang.OutOfMemoryError: Requested # java.lang.OutOfMemoryErro ...
- Java读写文件方法总结
Java读写文件方法总结 Java的读写文件方法在工作中相信有很多的用处的,本人在之前包括现在都在使用Java的读写文件方法来处理数据方面的输入输出,确实很方便.奈何我的记性实在是叫人着急,很多时候既 ...
- java调用本地方法的时候报错 could not find the main class:xx.program will exit
如图所示,当在java调用本地方法的时候报错 我的解决办法是把dll文件放到System.out.println(System.getProperty("java.library.path& ...
- 给NSString增加Java风格的方法
给NSString增加Java风格的方法 文章目录 我实在受不了 NSString 冗长的方法调用了,每次写之前都要查文档.特别是那个去掉前后多余的空格的方法,长得离谱.与之对应的别的语言,拿 jav ...
随机推荐
- pop()实现逐个删除数组最后一位并输出
使用pop()循环输出数组的最后一个元素 var a = []; a.push(1);a.push(3.1415926);a.push("number");a.push(" ...
- android ListView的怪异现象
我们已经知道,当条目没显示一次,那个类重写的最后一个函数就执行一次,但是现在,发生了怪异现象!当窗体的属性设置为包裹的时候,会重复显示多次,所以,高度,宽度都要设置为充满类型才可以
- 判断Featureclass的类型
一个Featureclass可以是Shapefile Feature Class.Personal Geodatabase Feature Class.File Geodatabase Feature ...
- [windows phone开发]新生助手的开发过程与体会二
上一讲咱们谈了新生助手主页的基本的设计,今天我们谈一谈关于展现实景地图时等动画的设计,即Storyboard的应用. 在Windows phone中,Storyboard类表示通过时间线控制动画,并为 ...
- 使用原生Sql查询实现按分类推送最新文章到首页
一般在网站的首页都会有网站最新文章的推送,而这些文章又属于不同的分类.如果某个分类的文章突然集中在一个时间段发布,那么就会造成首页上所有文章都是该分类的文章,其他的文章分类就变成不可见的了.所以,我希 ...
- Python的类变量和对象变量声明解析
Python的类和C++一样,也都是存在两种类型的变量,类变量和对象变量!前者由类拥有,被所有对象共享,后者由每个对象独有.这里我主要想讨论一下他们的声明办法. 首先说的是对象变量: 只要是声明在类的 ...
- 基础学习总结(七)--子线程及Handler
使用子线程获取网络图片1.采用httpUrlConnection直连方式获取图片2.采用子线程方式获取 <LinearLayout xmlns:android="http://sche ...
- jQuery插件css3动画模拟confirm弹窗
相比浏览器自带的alert.confirm,能力所及,我更喜欢所有的东西都是自定义:首先在head标签(当然喜欢其他地方自己看着办)内引入插件样式表和js.<link rel="sty ...
- 通过xsd生成xml类
步骤二:使用VS2010 Tools中的命令提示窗口 如下图所示 执行结果:生成myschema.xsd对应的C#类文件. 命令剖析: /c 生成对应的类文件 /l:cs 类文件使用C#语言 /ou ...
- Linux下如何卸载HP_LoadGenerator
很简单的一句命令就可以完全卸载! rpm -e LoadGenerator