我正在尝试将Security集成到ui:组合中。我正在从这个有用的链接得到帮助:https://raichand-java.blogspot.in/2016/12/springsecurity4primefaces5springdatajpa.html
它也能用。
但是,在ui:组合中集成了代码之后,我得到了一个异常。知道我添加了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">
<h:head>
<title>Login</title>
<h:outputScript library="primefaces" name="jquery/jquery.js"
target="head" />
<h:outputScript library="primefaces" name="jquery/jquery-plugins.js"
target="head" />
</h:head>
<h:body>
<ui:composition template="/templates/homeTemplate.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:sec="http://www.springframework.org/security/tags"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<center><h2>Login</h2></center>
<c:if test="${'fail' eq param.auth}">
<div style="color:red">
Login Failed!!!<br/>
Reason : Bad Credentials!Please Try Again.
</div>
</c:if>
<center>
<h:form prependId="false" id="form">
<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>
<p:spacer height="20px" width="10px"> </p:spacer>
<p:row>
<p:selectBooleanCheckbox label="Remember Me" id="remember-me" >Remember Me </p:selectBooleanCheckbox>
<h:outputText value=" " />
</p:row>
<br/>
<p:row>
<p:commandButton action="#{loginController.login()}" value="Login" ajax="false"/>
</p:row>
</h:form>
</center>
</ui:define>
</ui:composition>
</h:body>
</html>
我有个例外:
部署期间严重的javax.enterprise.resource.webcontainer.jsf.config关键错误::com.sun.faces.config.ConfigurationException:配置失败!org.springframework.faces.security.FaceletsAuthorizeTagHandler从模块"deployment.mission-man-ear.ear.mission-man-web.war:main“到服务模块加载器在com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:453)在com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)在io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)在io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100),org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82),java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511),java.util.concurrent.FutureTask.run(FutureTask.java:266),java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),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,但没有帮助我!我认为spring-security-taglibs 依赖型的版本存在一个问题。你知道如何解决这个问题吗。任何帮助都是非常感谢的。非常感谢。
发布于 2017-05-28 18:27:51
我没必要做新的改变。尝试运行As> Maven清洁,运行As> Maven安装,然后运行Maven>更新项目。就这样。
HTH
https://stackoverflow.com/questions/44215497
复制相似问题