Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.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
Jsf 从前进方向执行WEB-INF/page.xhtml中的commandButton Bean函数_Jsf_Servlets_Forward_Commandbutton_Web Inf - Fatal编程技术网

Jsf 从前进方向执行WEB-INF/page.xhtml中的commandButton Bean函数

Jsf 从前进方向执行WEB-INF/page.xhtml中的commandButton Bean函数,jsf,servlets,forward,commandbutton,web-inf,Jsf,Servlets,Forward,Commandbutton,Web Inf,我将Java EE用于Glassfish 4.1上的企业应用程序,我有以下组件: Java Servlet: protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8");

我将Java EE用于Glassfish 4.1上的企业应用程序,我有以下组件:

Java Servlet:

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    this.setUser(um.getLoggedUser());

    final String indexPath =  "/Index.xhtml";
    final String creatorPath =  "/WEB-INF/HiddenPages/EventPageCreator.xhtml";

    if(creator())
        request.getRequestDispatcher("/WEB-INF/HiddenPages/Creator.xhtml").forward(request, response);
    else
        response.sendRedirect("/Index.xhtml");
}
WEB-INF下的创建者页面是出现问题的页面: 它与ManagedBean方法相关

<h:form><p:menubar>
    <p:menuitem action="#{bean.logout()}" value="Logout" ajax="false">
</p:menuitem></p:menubar></h:form>

问题是page Creator.xhtlm正确地加载了所有css以及该bean提供的属性。问题是,一旦我单击“注销”菜单项,它就不会调用相关函数,并且出现500个内部错误,java.lang.IllegalStateException:在提交响应后无法转发。

为什么会出现这种尴尬的方法?答案是停止使用
RequestDispatcher#forward()
。非常感谢您的关注。问题是,通过使用sendRedirect转到WEB-INF下的页面,我陷入了404。这就是解决方案的原因。谢谢你的帮助不要把它们放在
/WEB-INF
中。这仅适用于使用JSP文件的MVC框架,这些文件不能映射到与视图文件本身相同的扩展名上<但是,code>FacesServlet可以很容易地映射到
*.xhtml
。而且,要执行基于用户角色的访问限制,请使用一个只调用
chain.doFilter()
的筛选器,而不是servlet。我已经尝试过这个解决方案,但primefaces主题的加载存在问题。即使它是在pom文件中声明的。你知道怎么修吗?这已经告诉你的同事了。
@ManagedBean
@RequestScoped
public class Bean(){
    public void logout(){
        System.out.println("logout");
    }
}