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
Jsf 2 使用PicketLink的基于PrimeFaces的应用程序在登录页面中不显示样式_Jsf 2_Primefaces_Picketlink - Fatal编程技术网

Jsf 2 使用PicketLink的基于PrimeFaces的应用程序在登录页面中不显示样式

Jsf 2 使用PicketLink的基于PrimeFaces的应用程序在登录页面中不显示样式,jsf-2,primefaces,picketlink,Jsf 2,Primefaces,Picketlink,我开发了一个基于PrimeFaces的应用程序,现在我想用CDI的方式使用PicketLink来保护它。我随后创建了一个登录页面,其中包含几个PrimeFaces组件(包括布局)。但是,所有样式和功能都将丢失。即使是简化的login.xhtml页面(与上面链接的示例相匹配)也没有样式 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://j

我开发了一个基于PrimeFaces的应用程序,现在我想用CDI的方式使用PicketLink来保护它。我随后创建了一个登录页面,其中包含几个PrimeFaces组件(包括布局)。但是,所有样式和功能都将丢失。即使是简化的login.xhtml页面(与上面链接的示例相匹配)也没有样式

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">
<h:head/>
<h:body>
  <p:panel>
    <h:form method="POST" prependId="false">
      <p:inputText id="j_username" />
      <p:password id="j_password"/>
      <p:commandButton id="login" value="Login" action="#{identity.login()}" ajax="false"/>
    </h:form>
  </p:panel>
  <p>Tip: you can login with a username/password of jane/abcd1234.</p>
</h:body>
</html>

提示:您可以使用用户名/密码jane/abcd1234登录


未加载css和js文件的原因是,原始示例中的安全“配置文件”除login.xhtml文件外,还保护了所有的资源。默认情况下,JSF从“virtual”
javax.faces.resource
文件夹加载资源。这需要从对的身份验证中排除。原始示例中的HttpSecurityConfiguration应进行调整,以排除配置中的此虚拟文件夹

public class HttpSecurityConfiguration {

    public void onInit(@Observes SecurityConfigurationEvent event) {
        SecurityConfigurationBuilder builder = event.getBuilder();

        builder
            .http()
                .forPath("/javax.faces.resource/*")
                    .unprotected()
                .forPath("/index.jsf")
                    .unprotected()
                .allPaths()
                    .authenticateWith()
                    .form()
                        .authenticationUri("/login.jsf")
                        .loginPage("/login.jsf")
                        .errorPage("/error.jsf")
                        .restoreOriginalRequest()
                .forPath("/logout")
                    .logout()
                    .redirectTo("/index.jsf");
    }
}