藏拙首页 | 贴吧 | 藏拙导航 | 藏拙IP搜索

 
查看文章
 



JBoss URL 重写学习笔记

2008年04月24日 15:07

JBoss URL ReWrite (重写)  学习笔记



第一: 将下面一行写入文件 : server.xml

<Valve className="org.jboss.web.rewrite.RewriteValve" />

The rewrite valve is configured as a regular valve, by adding the following to server.xml as child of an Engine or Host element (or inside a context.xml file):

<Valve className="org.jboss.web.rewrite.RewriteValve" />
 
第二:写入 RewriteRule 规则,方法跟 Apache 的 url ReWrite 完全一样!
但是必须写入 server.xml 中 If associated with an engine, it should be placed in a folder named [engine_name] placed either in the classloader, or in the conf folder of the current JBoss profile
什么意思呢?你必须写到在 server.xml 中配置 engine 这个节点 名称一样的目录下的 
rewrite.properties 文件中 ,如果是在 engine 这个节点的子节点,那你的目录也必须按照这个层次来建立!
 
这里感觉很奇怪哈,默认情况下 engine <Engine name="jboss.web" defaultHost="localhost"> 的 name 是 jboss.web
那就需要在 server.xml 文件所在目录下建立 jboss.web ,然后将 rewrite.properties 拷贝进去,这样一来 JBoss 的 url rewrite 重写才会起作用!
 
重写 url 的例子如下: 
RewriteRule ^/index.abc /index.jsp [L]
RewriteRule ^/2008([^/]+)/([^/]+).jpg /2008$1/$2 [L]
 
感觉跟 apache 没有任何区别,唯一就是这个建立跟节点名称一样的目录,另人讨厌!
 
呵呵

类别:学习笔记 | 浏览(173) | 评论 (0)
 
 
网友评论:
发表评论:
姓 名:
网 址:
内 容:




     


©2008 CangZhuo