在我的项目中使用PrimeFaces 5.1与JSF 2.2和PrettyFaces。如果没有在web.xml中使用prettyface来检查日志servletRequest.getRequestURI()将返回/myproject/page/home.xhml
。
但是同一个人在web.xml中添加了prettyfaces来检查logger现在它将打印 /myproject/javax.faces.resource/jsf.js.xhtml,/myproject/javax.faces.resource/css/myProjectCSS/external。 css.xhtml
为什么它不会打印当前网址
的web.xml
<filter>
<filter-name>SessionPage</filter-name>
<filter-class>sample.SessionPage</filter-class>
</filter>
<filter-mapping>
<filter-name>SessionPage</filter-name>
<servlet-name>Custom Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</filter-mapping>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
SessionPage
.....
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException
{
String contextPath = servletRequest.getRequestURI();
HttpSession session = ((HttpServletRequest) request).getSession(false);
HttpServletRequest servletRequest = (HttpServletRequest) request;
HttpServletResponse servletResponse = (HttpServletResponse) response;
system.out.println("Request URI: "+contextPath);
...
}
home.xhtml
<ui:composition ......>
<h:head>
<h:outputStylesheet name="/resource/css/myProjectCSS/external.css"/>
....
</h:head>
...
</ui:composition>
pretty.xml
<url-mapping id="home">
<pattern value="/home"/>
<view-id value="/faces/pages/home.xhtml"/>
</url-mapping>
<url-mapping id="user">
<pattern value="/user"/>
<view-id value="/faces/pages/user.xhtml"/>
</url-mapping>
然后我需要如果使用prettyfaces然后我需要requestURI到/ myproject / home 如何获得它?