找到你要的答案

Q:How to set a default error page for WildFly server?

Q:如何设置Wildfly服务器缺省的错误页面?

I'm using Wildlfy Application Server 8.2.0.Final. I have deployed an app.war file. In app's web.xml I can specify a home page and error pages. Which works perfectly for

local-host.com/app

url and for incorrect urls relative to it. When i type something like

local-host.com/app/xxx

I can see the specified page - that's great.

But when I enter

local-host.com

I can see WildFly's default page and when I type an incorrect one

local-host.com/xxx

I will se just 404 - Not Found

I would love to use same welcome and error pages from my app for these urls. I have found a reasonable solution for the welcome page here: How to auto direct to "my web application" from "root (/)" context in JBoss? which works fine, but I couldn't find out what can I do with errors.

Zigac's solution works great and mine "manual" solution works as well, but there is still an issue:

What to do with

local-host.com/META-INF

url - I still get server's default error message for it even despite that the url is under app's root?

Thx.

我用wildlfy应用服务器8.2.0.final。我有一个app.war文件部署。在应用的web.xml我可以指定一个主页和页面错误。完美的工作

local-host.com/app

URL和不正确的URL相对于它。当我打字时

local-host.com/app/xxx

我可以看到指定的页面-这是伟大的。

但当我进入

local-host.com

我可以看到WildFly的默认页面,当我键入一个不正确的人

local-host.com/xxx

我将只硒404 -没有找到

我喜欢使用相同的欢迎和错误页面从我的应用程序为这些网址。我发现这里的欢迎页面的一个合理的解决方案:如何自动指向“我的Web应用程序”从“根(/)”的语境在JBoss的?这工作很好,但我找不到我可以做什么与错误。

Zigac的解决方案的伟大工程和矿山“手动”解决方案为好,但仍有一个问题:

怎么办

local-host.com/meta-inf

URL -我仍然得到服务器的默认错误信息,即使它的URL是根据应用程序的根?

谢谢.

answer1: 回答1:

Define context-root as '/' in jboss-web.xml

<jboss-web>
    <context-root>/</context-root>
</jboss-web>

And add custom mapping for every error code web.xml

<error-page>
    <error-code>404</error-code>
    <location>/error-page-not-found.jsp</location>
</error-page>

定义上下文根为“/”jboss-web.xml

<jboss-web>
    <context-root>/</context-root>
</jboss-web>

并添加每个错误代码web.xml自定义映射

<error-page>
    <error-code>404</error-code>
    <location>/error-page-not-found.jsp</location>
</error-page>
answer2: 回答2:

I changed localhost alias setting for WildFly's HTTP server and specified my app's war instead of the default root.war. This solution unlike the one with redirecting to my app's url from the default app server's index.html(in welcome-content directory) allows all the "/" related urls be interpreted as my app's related urls and thus the provided error pages mapping from app.war web.xml works perfectly for all incorrect urls.

I used WildFly's administration console(9090) to change HTTP server settings: Configuration -> Web->HTTP->Hosts->Default web-module .

Thx.

我改变了本地主机别名设定Wildfly的HTTP服务器和指定我的APP的战争而不是默认的root.war。该方案与重定向到我的应用程序的URL从默认的应用程序服务器的指标之一。HTML(欢迎内容目录)允许所有“/”相关的网址被解释为我的应用程序的相关网址,从而提供错误页面映射app.war web.xml的作品完美的一切不正确的URL。

我使用Wildfly的管理控制台(9090)改变HTTP服务器设置:配置>;网络& gt;HTTP & gt;主持>;默认Web模块。

谢谢.

java  url  default  wildfly-8  servlet-3.0