Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在JSF中访问受保护的页面_Java_Jsf 2_Primefaces_Navigation - Fatal编程技术网

Java 在JSF中访问受保护的页面

Java 在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-

我已经找到了一种方法,通过在my web.xml中设置此安全约束来保护对my
.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)}"/>