2017-05-27 43 views
0

我試圖在ui內部集成Spring Security:組合。 我從這個有用的鏈接中獲得幫助:https://raichand-java.blogspot.in/2016/12/springsecurity4primefaces5springdatajpa.html在ui中集成Spring Security時出現異常:構圖

它也適用。

但是,在ui:composition裏面集成代碼之後,我得到了一個異常。 知道我添加的文件springsecurity.taglib.xml

<?xml version="1.0"?> 
 
<!DOCTYPE facelet-taglib PUBLIC 
 
    "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" 
 
    "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"> 
 
<facelet-taglib> 
 
    <namespace>http://www.springframework.org/security/tags</namespace> 
 
    <tag> 
 
     <tag-name>authorize</tag-name> 
 
     <handler-class>org.springframework.faces.security.FaceletsAuthorizeTagHandler</handler-class> 
 
    </tag> 
 
    <function> 
 
     <function-name>areAllGranted</function-name> 
 
     <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class> 
 
     <function-signature>boolean areAllGranted(java.lang.String)</function-signature> 
 
    </function> 
 
    <function> 
 
     <function-name>areAnyGranted</function-name> 
 
     <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class> 
 
     <function-signature>boolean areAnyGranted(java.lang.String)</function-signature> 
 
    </function> 
 
    <function> 
 
     <function-name>areNotGranted</function-name> 
 
     <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class> 
 
     <function-signature>boolean areNotGranted(java.lang.String)</function-signature> 
 
    </function> 
 
    <function> 
 
     <function-name>isAllowed</function-name> 
 
     <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class> 
 
     <function-signature>boolean isAllowed(java.lang.String, java.lang.String)</function-signature> 
 
    </function> 
 
</facelet-taglib>

我添加到文件web.xml中

<context-param> 
 
     <param-name>javax.faces.FACELETS_LIBRARIES</param-name> 
 
     <param-value>/WEB-INF/springsecurity.taglib.xml</param-value> 
 
    </context-param>

運行該頁面後:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" 
 
     xmlns:h="http://java.sun.com/jsf/html" 
 
     xmlns:f="http://java.sun.com/jsf/core" 
 
     xmlns:ui="http://java.sun.com/jsf/facelets" 
 
     xmlns:c="http://java.sun.com/jsp/jstl/core" 
 
     xmlns:p="http://primefaces.org/ui"> 
 
\t <h:head> 
 
     <title>Login</title> 
 
     <h:outputScript library="primefaces" name="jquery/jquery.js" 
 
\t \t target="head" /> 
 
\t <h:outputScript library="primefaces" name="jquery/jquery-plugins.js" 
 
\t \t target="head" /> 
 
\t </h:head> 
 
\t <h:body> 
 
\t 
 
\t \t <ui:composition template="/templates/homeTemplate.xhtml" 
 
\t \t \t \t \t \t xmlns="http://www.w3.org/1999/xhtml" 
 
\t \t \t \t \t  xmlns:ui="http://java.sun.com/jsf/facelets" 
 
\t \t \t \t \t  xmlns:h="http://java.sun.com/jsf/html" 
 
\t \t \t \t \t  xmlns:sec="http://www.springframework.org/security/tags" 
 
\t \t \t \t \t  xmlns:p="http://primefaces.org/ui"> 
 
\t \t 
 
\t \t 
 
\t \t <ui:define name="content"> \t 
 
    \t <center><h2>Login</h2></center> 
 
\t \t <c:if test="${'fail' eq param.auth}"> 
 
    \t \t <div style="color:red"> 
 
     \t \t Login Failed!!!<br/> 
 
      \t Reason : Bad Credentials!Please Try Again. 
 
    \t \t </div> 
 
\t \t </c:if> 
 
     \t <center> 
 
     \t \t <h:form prependId="false" id="form"> 
 
     \t \t <p:panelGrid columns="2" style="border-bottom-width: 0px;"> 
 
       <h:outputText value="UserName:"/> 
 
       <p:inputText value="#{loginController.username}" id="username" required="true" requiredMessage="UserName is required"/> 
 
       <h:outputText value="Password:"/> 
 
       <p:password value="#{loginController.password}" id="password" required="true" requiredMessage="Password is required"/> 
 
      </p:panelGrid> 
 
     \t  <p:spacer height="20px" width="10px"> </p:spacer> 
 
     \t  <p:row> 
 
     \t  \t <p:selectBooleanCheckbox label="Remember Me" id="remember-me" >Remember Me </p:selectBooleanCheckbox> 
 
     \t   <h:outputText value=" " /> 
 
     \t  </p:row> 
 
     \t  <br/> 
 
     \t  <p:row> 
 
     \t  \t <p:commandButton action="#{loginController.login()}" value="Login" ajax="false"/> 
 
     \t  \t </p:row> 
 
     \t </h:form> 
 
\t \t </center> 
 
\t \t </ui:define> 
 
\t </ui:composition> 
 
\t 
 
\t </h:body> 
 
</html>

我得到這個異常:

嚴重[javax.enterprise.resource.webcontainer.jsf.config(Server服務線程池 - - 175)部署過程中出現嚴重錯誤::com.sun.faces.config.ConfigurationException:CONFIGURATION FAILED! org.springframework.faces.security.FaceletsAuthorizeTagHandler from [module「deployment.mission-man-ear.ear.mission-man-web.war:main」from Service Module Loader] at com.sun.faces.config.ConfigManager。初始化(ConfigManager.java:453) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227) at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100) at org.wildfly.extension.undertow。部署.UndertowDeploymentService $ 1.run(UndertowDeploymentService.java:82) at java.util.concurrent.E xecutors $ RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748) at org.jboss.threads.JBossThread.run(JBossThread.java: 320)

谷歌搜索後,我發現這個線程java.lang.ClassNotFoundException: org.springframework.faces.security.FaceletsAuthorizeTagHandler,但沒有幫助我!我認爲存在版本彈簧安全標籤庫依賴版本的問題。你有什麼想法解決這個問題。任何幫助表示讚賞。非常感謝。

回答

0

我不需要做出新的改變。 試試運行方式> Maven Clean,運行方式> Maven安裝Maven>更新項目。 就是這樣。

HTH