如何在 JSF 中使用 Spring Security Facelets 标记库 [英] How to use the Spring Security Facelets tag library in JSF
问题描述
我想使用 Spring Security Facelets 标记库来保护我的 UI 组件在我的 JSF 2 页面
i want to use The Spring Security Facelets tag library to secure my UI components in my JSF 2 pages
我对 spring 安全版本 3.0.5 有以下依赖项:
i have following dependencies for spring security version 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 安全登录,它工作正常使用 UserDetailsService,并在尝试添加安全定义时:
i configured applicationSecurity.xml to make spring security login, and it works fine with UserDetailsService, and when tried to add the security definition:
<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">
在运行应用程序时,出现以下错误:
and when running the application, i got following error:
Warning: This page calls for XML namespace http://www.springframework.org/security/tags declared with prefix sec but no taglibrary exists for that namespace.
参考:http://static.springsource.org/spring-security/site/petclinic-tutorial.html
请指教.
推荐答案
你需要先添加springsecurity.taglib.xml如此处所述:
You will need to add springsecurity.taglib.xml first as mentioned here:
并且你应该在你的类路径中有 org.springframework.faces jar 以便使用它.
and you should have the org.springframework.faces jar in your classpath in order to use it.
然后使用如下安全标签:
then use the security tags as follows:
<!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 标记库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!