my site uses JSF and the url appears to be, http://mysitename.com/wompower6/faces/home.xhtml
I am using prettyfaces, so if I use the following in pretty-config.xml, i can change the name to http://mysitename.com/wompower6/home
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/faces/home.xhtml" />
</url-mapping>
my questions are
how can i remove the application name wompower6 , so that the url becomes mysitename.com/home ?
in my web.xml, i have
<welcome-file>home.xhtml</welcome-file>
, but this does not seem to work. When i type, mysitename.com, it does not get mapped to home.xhtml. any clue here?
how can i remove the application name wompower6 , so that the url becomes mysitename.com/home?
This is a webapp <Context>
setting and configuration is dependent on the servletcontainer used. If you're for example using Tomcat, then there are basically 2 options to make your webapp the root webapp.
Rename the WAR file to
ROOT.war
and Tomcat will by default deploy it on context root.Set
path
attribute of<Context>
element inWebapp/META-INF/context.xml
(orTomcat/conf/server.xml
, depending where you'd like to define it) to an empty String. E.g.<Context path="" ...>
Other containers support similar constructs. Consult their documentation for detail. If you're using an IDE like Eclipse, then you can also set it in the Web Project Settings property of the project properties (rightclick project and choose Properties). Set the Context root value to just /
.
in my web.xml, i have home.xhtml, but this does not seem to work. When i type, mysitename.com, it does not get mapped to home.xhtml. any clue here?
I assume that you're talking about the <welcome-file>
setting. This has to point to a physically existing file, not to a virtual URL, such as /faces/*
. There are basically two ways to overcome this:
Provide a physically existing
/faces/home.xhtml
file (it can even be left empty).Replace the ugly
/faces/*
URL pattern of theFacesServlet
mapping inweb.xml
by*.xhtml
so that it will just kick in on every request for a XHTML file.<url-pattern>*.xhtml</url-pattern>
This way you don't need to fiddle with
/faces/*
URL patterns.
来源:https://stackoverflow.com/questions/6546951/remove-application-name-from-url