开发者

Tomcat7 open index.html from directory

I have webapp in JSF2, something like mywebdomain.com/mywebsite/portal/index.xhtml

Now I need to add an admin interface, I have created admin folder and this is working well mywebdomain.com/mywebsite/portal/admin/index.xhtml

Users of this application will certainly not remember this URL, so I want to create "shortcut"

http://mywebdomain.com/mywebsite/admin

In this folder is a plain index.html with

<meta http-equiv="refresh" content="0;url=/mywebsite/portal/admin/index.xhtml" />

BUT... when I type http://mywebdomain.com/mywebsite/admin, Tomcat7 shows HTTP Status 404 - /mywebsite/admin/ ... description The requested resource (/mywebsite/admin/) is not available.

So is there a way how to create th开发者_如何学JAVAis "shortcut"?

Thanks in advance :)


You need to define index.html as a <welcome-file> in web.xml. This way the container will lookup for the given file whenever a directory is been requested instead of a file.

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

Alternatively, you can also just define index.xhtml as a welcome file, then you don't need the index.html file with the meta refresh tag workaround at all, the container will then just lookup the index.xhtml directly.

<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜