How to set default error page for WildFly server?

I am using Wildlfy Application Server 8.2.0.Final. I deployed the app.war file. In app web.xml, I can specify home and error pages. Which works great for

local-host.com/app

url and for invalid urls relative to it. When I type something like

local-host.com/app/xxx

I see the specified page - that's great.

But when I enter

local-host.com

I can see the default WildFly page and when I print the wrong one

local-host.com/xxx

I'll just 404 - Not Found

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

Zigac's solution works great and my "manual" solution works, but there is still a problem:

What to do with

local-host.com/META-INF

url - am I still getting the default error for the server even though the url is under the root of the application?

thank.

+3


source to share


2 answers


I changed the localhost alias setting for the WildFly HTTP server and specified my war in the app instead of the default root.war. This solution, as opposed to the one redirecting to my app url from the default app server index.html (in the greeter-content directory), allows all linked urls "/" to be interpreted as links linked to my app. and thus the provided display of error pages from app.war web.xml works fine for all invalid urls.

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



thank.

+1


source


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

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

      



And add custom mapping for each web.xml error code

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

      

+1


source







All Articles