标签:hal jar context 其他 inf com bsp war 4.0
资源
UrlRewrite概念可参考: http://blog.csdn.net/crazy1235/article/details/8585310
UrlRewrite第三方库: http://tuckey.org/urlrewrite/
WildFly下载: http://wildfly.org/downloads/
安装及相关配置
"WEB-INF/web.xml"的头部添加以下内容:
<filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>
要使用第三方UrlRewrite库则需要把"urlrewritefilter-4.0.3.jar"拷贝到Web App的"WEB-INF/lib",然后在"WEB-INF"下添加如下jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?> <jboss-web xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd"> <context-root>/</context-root> </jboss-web>
UrlRewrite规则定义在如下"WEB-INF/urlrewrite.xml"文件:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN" "http://tuckey.org/res/dtds/urlrewrite2.6.dtd"> <urlrewrite> <rule> <from>/hello/abc/</from> <to type="forward">/</to> </rule> <rule> <from>/hallo/</from> <to type="forward">/</to> </rule> </urlrewrite>
完成部署和相关配置后,可以通过以下Urls访问部署的Web App:
http://localhost:8080/ http://localhost:8080/hello/abc/
http://localhost:8080/hallo/
标签:hal jar context 其他 inf com bsp war 4.0
原文地址:http://www.cnblogs.com/jinzd/p/7514216.html