当前位置: 首页 > 知识库问答 >
问题:

在jsf项目中使用Spring Security标签库需要哪些配置和库?

柯宜年
2023-03-14

我想在我的jsf项目中使用spring security标记库,所以我对项目做了以下更改,但是我得到了这个异常:

Error occurred during deployment: Exception while loading the app :

java.lang.IllegalStateExc的:ContainerBase.add子级:开始:org.apache.catalina.生命周期异常:java.lang.运行时异常:com.sun.faces.config.配置异常:源文档: jar: file:/C:/用户/omid4/桌面/omidrcs/最终/omidrcs/omidrcs/构建/web/WEB-iNF/lib/org.springframework.faces-2.3.1.RELEASE.jar! /META-INF/faces-config.xml原因:无法创建新的实例

我在这里做错了什么?我有其他配置吗?我使用 :

NetBeans 7.1.2 --Spring MVC 3.0.6-- Spring Security 3.1.1--Glassfish 3.1.2 和 JSF 2.1

springsecurity.taglib.xml:

   <!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>

网站.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">


<!--  /========================jsf config=============================/-->

  <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>#{sessionManager.theme}</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
     <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>/index.xhtml</welcome-file>
    </welcome-file-list>

  <!--  /========================spring config=============================/-->  

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml
            /WEB-INF/spring-security.xml
        </param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
    <listener-class>
      org.springframework.security.web.session.HttpSessionEventPublisher
    </listener-class>
  </listener>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>
            org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

</web-app>

mypage.xhtml:

xmlns:sec="http://www.springframework.org/security/tags"
.
.
.
<sec:authorize access="ROLE_SUPERADMIN">
      <h:outputText value="test" />                          
</sec:authorize>

mylib:

    org.springframework.cglib-2.2   3.0.6.RELEASE
    org.springframework.aop 3.0.6.RELEASE
    org.springframework.asm 3.0.6.RELEASE
    org.springframework.aspects 3.0.6.RELEASE
    org.springframework.beans   3.0.6.RELEASE
    org.springframework.context 3.0.6.RELEASE
    org.springframework.context.support 3.0.6.RELEASE
    org.springframework.core    3.0.6.RELEASE
    org.springframework.expression  3.0.6.RELEASE
    org.springframework.instrument 3.0.6.RELEASE
    org.springframework.expression  3.0.6.RELEASE
    org.springframework.jdbc    3.0.6.RELEASE
    org.springframework.jms 3.0.6.RELEASE
    org.springframework.orm 3.0.6.RELEASE
    org.springframework.oxm 3.0.6.RELEASE
    org.springframework.test    3.0.6.RELEASE
    org.springframework.tx  3.0.6.RELEASE
    org.springframework.web 3.0.6.RELEASE
    org.springframework.webmvc-portlet  3.0.6.RELEASE
    org.springframework.webmvc  3.0.6.RELEASE
    org.springframework.struts  3.0.6.RELEASE
    commons-logging-1.1.1
    jsf 2.1-jsf-api
    jsf 2.1 -jsf-impl
    jstl 1.1-standard
    jstl 1.1-jstl
    spring-security-ldap-3.1.1.RELEASE.jar
    spring-security-config-3.1.1.RELEASE.jar
    spring-security-core-3.1.1.RELEASE.jar
    spring-security-taglibs-3.1.1.RELEASE.jar
    spring-security-web-3.1.1.RELEASE.jar
    org.springframework.webflow-2.0.3.jar
    org.springframework.binding-2.0.3.jar

共有1个答案

赏育
2023-03-14

我用删除库解决了这个问题:org.springframework.webflow-2.0.3.jar org.springfframework.binding-2.03.jar

并从 http://www.springsource.org/download/community?project=Spring%20Web%20Flow 下载org.springframework.webflow-2.3.1和依赖项并解决异常

 类似资料:
  • 我正在使用Cucumber插件在Eclipse中运行特性文件。我正在尝试使用标记来选择要运行的方案。 在我的特性文件中,我使用如下所示的不同标记标记了两个场景:

  • 我们已经在现有的HDP上安装了nifi(HDF服务)。安装是成功的,我可以运行nifi没有任何错误。但我在PutHDFS中遇到了一个问题 我也附上了截图。

  • 我有一个使用AspectJ的Spring项目。在99.9%的情况下,使用AspectJ(ajc)CTW my aspects按预期工作。 然而,在一个特殊的情况下,我发现我需要围绕着Spring的相位来编织相位。更具体地说,我想包装一个Spring@Transactional。 如果我使用AspectJ ajc来CTW我的建议,它将围绕任何定义为@Transactional的方法进行编织。相反,我

  • 本文向大家介绍请说说你做过的项目中,使用过哪些JSTL标签?相关面试题,主要包含被问及请说说你做过的项目中,使用过哪些JSTL标签?时的应答技巧和注意事项,需要的朋友参考一下 考察点:JSTL   项目中主要使用了JSTL的核心标签库,包括c:if、c:choose、<c: when>、<c: otherwise>、c:forEach等,主要用于构造循环和分支结构以控制显示逻辑。 虽然JSTL标签

  • 一旦你将packaging设置为pom,你需要groupID、artifactId和version标签吗?如果需要,它们有什么用途?有没有应该使用的标记(毕竟groupID显然是针对java的,所以如果有其他语言或工件类型特定的标记应该使用,我也不会感到惊讶)。样品: 简单的父pom: 简单的孩子pom: 然后子孩子是各种项目的许多类型,java,C,角,python,更多的poms。

  • 更新-所以肯定是为了搜索丢失的依赖项,这是为了什么?