【发布时间】:2014-04-04 11:35:28
【问题描述】:
我找到了一种方法来保护对我的.xhtml 页面的直接访问,方法是在我的 web.xml 中添加此安全约束:
<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>
但是这似乎限制了我在 web.xml 中的欢迎文件列表,我有这样的:
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
我似乎也无法通过这种方法从 bean 访问我的页面:
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);
}
}
上述方法的xhtml:
<p:menuitem value="Break Even Rate Profit report"
action="#{Navigation.getBreakEvenProductPage(event)}"/>
我的问题是我通过尝试解决问题提出了另一个问题。如何在安全约束到位的情况下访问这些页面??
【问题讨论】:
标签: java jsf-2 primefaces navigation