Java 在JSF中访问受保护的页面
我已经找到了一种方法,通过在my web.xml中设置此安全约束来保护对myJava 在JSF中访问受保护的页面,java,jsf-2,primefaces,navigation,Java,Jsf 2,Primefaces,Navigation,我已经找到了一种方法,通过在my web.xml中设置此安全约束来保护对my.xhtml页面的直接访问: <security-constraint> <display-name>Restrict raw XHTML Documents</display-name> <web-resource-collection> <web-resource-name>XHTML</web-
.xhtml
页面的直接访问:
<security-constraint>
<display-name>Restrict raw XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint />
</security-constraint>
上述方法的xhtml:
<p:menuitem value="Break Even Rate Profit report"
action="#{Navigation.getBreakEvenProductPage(event)}"/>
我的问题是,我试图解决一个问题,却又遇到了另一个问题。在安全约束已就位的情况下,我如何访问这些页面???您可以尝试更改
faces/index.xhtml
到
faces/index.jsf
并确保您的web.xml中有以下行
Facesservlet
*.jsf
Facesservlet
*.xhtml
public void getBreakEvenProductPage(ComponentSystemEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest origRequest = (HttpServletRequest) context.getExternalContext().getRequest();
String contextPath = origRequest.getContextPath();
try {
FacesContext.getCurrentInstance().getExternalContext()
.redirect(contextPath + "/faces/BreakEvenProfProduct.xhtml");
} catch (IOException e) {
log.debug(Level.FATAL, e);
}
}
<p:menuitem value="Break Even Rate Profit report"
action="#{Navigation.getBreakEvenProductPage(event)}"/>