How to auto direct to “my web application” from “root (/)” context in JBoss?

心不动则不痛 提交于 2019-12-02 23:09:43

You need to keep index.html in default deploy folder and forward request to your web module.

For example keep following line only in index.html

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/test/"/> 
ph4r05

The answer from Senthil works nice, but user could see the actual redirect done by the browser (page blinks). The redirect can be done also with rewrite [1, 2] functionality of the JBoss server, which supports HTTP Redirect with 30x codes (no blink).

You can either add the rewrite to your app directly (web.xml, jboss-web.xml) and specify the redirect rules in rewrite.properties - not shown here.

Or you can modify the server configuration on it's own without touching the original application. I find this solution handy because the application is left intact.

Use case: We use this for EJBCA deployment (not our app), it sets it's context root to /ejbca. We want to preserve the default deployment process provided by the packaged ant script while in the same time we would like to add a redirect from / to /ejbca as some kind of default, for user friendliness. If user wants to change it, it's done simply by modifying standalone.xml without need to redeploy the whole app.

Edit standalone.xml:

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
    <virtual-server name="default-host" enable-welcome-root="true">
        <alias name="localhost"/>
        <rewrite pattern="^/$" substitution="/test" flags="L,QSA,R" />
    </virtual-server>
</subsystem>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!