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 ...
随机推荐
- FTP协议及工作原理详解
1. FTP协议 什么是FTP呢?FTP 是 TCP/IP 协议组中的协议之一,是英文File Transfer Protocol的缩写. 该协议是Internet文件传送的基础,它由一系列规格说明文 ...
- C语言 猜数游戏--产生一个随机数
#include <stdio.h> #include <time.h> #include <stdlib.h> int main(int argc, const ...
- C# 语言如何获取json格式的数据,不用javascript用c#实现。。。
{'state' : 1,'data':{'list':[{'id': 123, 'name': '诸葛天邪','level': 10,'country': 1,}]}} 比如我要获取里面的 id 该 ...
- Geoserver 相关学习
参考资料: http://geoserver.org/ http://docs.geoserver.org/ 相关文档 http://docs.geoserver.org/stable/en/user ...
- Color About——Second
下面来简要的说一下Android开发中如何对某一个Activity进行背景色的设置.下面我以名字为FirstActivity的Activity的背景色的设置进行说明,先说一下Drawable类: 关于 ...
- How to begin Python learning?
如何开始Python语言学习? 1. 先了解它,Wiki百科:http://zh.wikipedia.org/zh-cn/Python 2. Python, Ruby等语言来自开源社区,社区的学法是V ...
- C#学习笔记一
c#学习笔记一 c#学习笔记一 1 1. 注释 3 1.1. ///是文档注释,用于类和方法的说明 3 1.2. #region #endregion可以折叠代码 ...
- [转]Linux下修改/设置环境变量JAVA_HOME
1. 永久修改,对所有用户有效 # vi /etc/profile //按键盘[Shift + g], 在profile文件最后添加下面的内容: export JAVA_HOME = /home/m ...
- 【转载】Powershell获取世纪互联Office365所有用户最后一次登录时间
#$Mails=get-mailbox -ResultSize 10 $Mails=get-mailbox -ResultSize Unlimited $Mails | Measure-Object ...
- ActiveMQ.xml文件的主要配置
ActiveMQ.xml文件默认位置位于 activemq/conf/目录下,主要的配置及解析如下:<beans xmlns="http://www.springframework.o ...