如何在JSF中使用Spring Security Facelets标记库

我想使用Spring Security Facelets标记库来保护我的JSF 2页面中的UI组件

我对Spring Security版本3.0.5具有以下依赖性:

<dependency>

<groupId>org.springframework.security</groupId>

<artifactId>spring-security-core</artifactId>

<version>${spring-security.version}</version>

</dependency>

<dependency>

<groupId>org.springframework.security</groupId>

<artifactId>spring-security-web</artifactId>

<version>${spring-security.version}</version>

</dependency>

<dependency>

<groupId>org.springframework.security</groupId>

<artifactId>spring-security-config</artifactId>

<version>${spring-security.version}</version>

</dependency>

<dependency>

<groupId>org.springframework.security</groupId>

<artifactId>spring-security-taglibs</artifactId>

<version>${spring-security.version}</version>

</dependency>

我配置了applicationSecurity.xml以进行Spring安全性登录,并且它可以与UserDetailsS​​ervice一起正常工作,并且在尝试添加安全性定义时:

<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:ice="http://www.icesoft.com/icefaces/component"

xmlns:pretty="http://ocpsoft.com/prettyfaces"

xmlns:sec="http://www.springframework.org/security/tags">

当运行该应用程序时,出现以下错误:

Warning: This page calls for XML namespace http://www.springframework.org/security/tags declared with prefix sec but no taglibrary exists for that namespace. 

回答:

你将需要首先添加springsecurity.taglib.xml,如下所述:

并且你应该在类路径中具有org.springframework.faces jar才能使用它。

然后使用安全标签,如下所示:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition 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">

以上是 如何在JSF中使用Spring Security Facelets标记库 的全部内容, 来源链接: utcz.com/qa/413071.html

回到顶部