Setting application URL on WAS server, where does

2019-09-07 15:40发布

How is the URL set when an application is deployed on WAS server? Other than the context path I am setting, I am getting a /faces/ in the URL. I have no clue from where this is coming from.

标签: jsf url
1条回答
等我变得足够好
2楼-- · 2019-09-07 16:14

The /faces/ is recognizable as JSF 1.0/1.1-style URL pattern where FacesServlet is often by default mapped on based on IDE-generated project configuratoin which weren't edited afterwards by the developer. You can see this in web.xml as something like this:

<servlet-mapping>
    <servlet-name>Faces Servlet<servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

Perhaps there's also a <welcome-file> on e.g. faces/index.xhtml or so.

In order to get rid of it, just replace it by *.xhtml.

<servlet-mapping>
    <servlet-name>Faces Servlet<servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

This way you can open the JSF page by http://example.com/context/page.xhtml instead of http://example.com/context/faces/page.xhtml in order to trigger the FacesServlet (it's namely the one responsible for all the JSF works).

Or, when you're actually using legacy JSF 1.x and/or when you're actually using legacy JSP instead of its successor Facelets (XHTML), then you could use *.jsf instead.

<servlet-mapping>
    <servlet-name>Faces Servlet<servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

This way you can open the JSF page by http://example.com/context/page.jsf instead of http://example.com/context/faces/page.jsp.

See also:

查看更多
登录 后发表回答