Resources
Urlrewrite concept can be consulted: http://blog.csdn.net/crazy1235/article/details/8585310
Urlrewrite third-party library: http://tuckey.org/urlrewrite/
Wildfly Download: http://wildfly.org/downloads/
Installation and related configuration
- After completing the Wildfly download under Ubuntu, perform the "unzip Wildfly-10.1.0.final.zip "Unzip wildfly to the current directory, after completing this step you can move wildfly to other specified directories as needed, and modify the directory name such as" Wildfly10 ".
- Enter "./wildfly/bin" and execute "add-user.sh" to add a new user, such as "admin", this process specifies that the user role is not important.
- After completing the user registration, execute "standalone.sh" to start Wildfly application Server.
- After the server is started, access by default: http://localhost:9990 deploy the Web app to complete the deployed app from http://localhost:8080 access.
Add the following to the head of "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>
To use a third-party Urlrewrite library, you need to copy "Urlrewritefilter-4.0.3.jar" to the "web-inf/lib" of the WEB app, and then add the following jboss-web.xml under "Web-inf":
<?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>
The urlrewrite rule is defined in the following "Web-inf/urlrewrite.xml" file:
<?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>
Once the deployment and related configurations are complete, you can access the deployed Web App through the following URLs:
http://localhost:8080/http://localhost:8080/hello/abc/
http://localhost:8080/hallo/
Wildfly and Urlrewrite