异常:The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application
需要添加spring-security-taglibs-3.0.5.RELEASE.jar包及其依赖包
对于spring security我只是初学者,原来只是想找一个用于权限验证的源码借鉴一下,结果一搜索,就搜到了spring security安全机制框架,我现在要将这个安全机制框架整合到我原来的ssh项目中去。
我现在只是在实验和学习阶段,没有深入的东西,用户名密码及其权限均是在xml文件配置的,以后有时间再学习一下如何和数据库交互,下面仅是简单的整合,将spring security的示例整合到项目中去。如果你是下载的spring security的发行包,会在其dist目录下找到一个spring-security-samples-tutorial-x.x.x.xxxxx.war的war包,我直接使用了这里的applicationContext-security.xml和jsp文件。
下面开始整合:
1.首先添加jar包依赖,我使用的maven来管理依赖包,只需添加下面依赖:
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-core</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-web</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-config</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
版本号自己控制,我使用的3.0.5.RELEASE版本,自己手动管理jar包依赖的,将dist目录下的除了war包和***-sources.jar外的所有jar包添加项目下。
2.在web.xml下配置spring security的过滤器和spring security的配置文件的位置,这里注意,在ssh框架整合spring security时,一定要将spring security的filter-mapping配置在struts2的filter-mapping之前,否则会出现如下错误:
- HTTP ERROR 404
- Problem accessing /Struts_Spring_Maven/spring_security_login. Reason:
- There is no Action mapped for namespace [/] and action name [spring_security_login] associated with context path [/Struts_Spring_Maven].
struts2和spring security配置如下:
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>
- classpath:applicationContext.xml
- /WEB-INF/applicationContext-security.xml
- </param-value>
- </context-param>
- <!-- 配置Struts中心过滤器 -->
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
- <init-param>
- <param-name>actionPackages</param-name>
- <param-value>zwh.struts.maven.action</param-value>
- </init-param>
- </filter>
- <!-- 配置spring security的过滤器 -->
- <filter>
- <filter-name>springSecurityFilterChain</filter-name>
- <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
- </filter>
- <!-- spring security的filter-mapping一定要配置struts的前面 -->
- <filter-mapping>
- <filter-name>springSecurityFilterChain</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!-- struts的filter-mapping -->
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
3.添加applicationContext-security.xml文件,我是直接将示例项目中的文件直接拷贝到我的项目中去的,拷贝到WEB-INF目录下。文件内容如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <beans:beans xmlns="http://www.springframework.org/schema/security"
- xmlns:beans="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
- <global-method-security pre-post-annotations="enabled">
- <!-- AspectJ pointcut expression that locates our "post" method and applies security that way
- <protect-pointcut expression="execution(* bigbank.*Service.post*(..))" access="ROLE_TELLER"/>
- -->
- </global-method-security>
- <http use-expressions="true">
- <intercept-url pattern="/secure/extreme/**" access="hasRole('ROLE_SUPERVISOR')"/>
- <intercept-url pattern="/secure/**" access="isAuthenticated()" />
- <!-- Disable web URI authorization, as we're using <global-method-security> and have @Secured the services layer instead
- <intercept-url pattern="/listAccounts.html" access="isRememberMe()" />
- <intercept-url pattern="/post.html" access="hasRole('ROLE_TELLER')" />
- -->
- <intercept-url pattern="/**" access="permitAll" />
- <form-login />
- <logout />
- <remember-me />
- <!--
- Uncomment to enable X509 client authentication support
- <x509 />
- -->
- <!-- Uncomment to limit the number of sessions a user can have -->
- <session-management invalid-session-url="/timeout.jsp">
- <concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
- </session-management>
- </http>
- <!--
- Usernames/Passwords are
- rod/koala
- dianne/emu
- scott/wombat
- peter/opal
- -->
- <authentication-manager>
- <authentication-provider>
- <password-encoder hash="md5"/>
- <user-service>
- <user name="rod" password="a564de63c2d0da68cf47586ee05984d7" authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" />
- <user name="dianne" password="65d15fe9156f9c4bbffd98085992a44e" authorities="ROLE_USER,ROLE_TELLER" />
- <user name="scott" password="2b58af6dddbd072ed27ffc86725d7d3a" authorities="ROLE_USER" />
- <user name="peter" password="22b5c9accc6e1ba628cedc63a72d57f8" authorities="ROLE_USER" />
- </user-service>
- </authentication-provider>
- </authentication-manager>
- </beans:beans>
从该文件中可以看到/secure路径下面的所有文件的访问需要登陆才能访问,而/secure/extreme路径下的所有文件的访问必须是超级用户,即具备ROLE_SUPERVISOR的角色。rod是超级用户,密码是koala,后面登陆需要使用。
4.在项目目录下创建secure目录和secure/extreme目录,并在这些目录下放一些需要验证才能访问的页面,我为了省事,将示例中jsp页面直接拷贝到项目目录下了。
5.下面将该项目添加到tomcat中去,运行,访问http://localhost:8080/项目名称/secure/index.jsp 。这时你发现并不是展示出你访问的页面,而是出现了一个登陆页面。如下:
6.输入用户名rod和密码koala,提交,这时就可以看到了你想要访问的页面了。
7.如果遇到如下问题:
- The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application.
对于maven还需要添加如下依赖
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-taglibs</artifactId>
- <version>3.0.5.RELEASE</version>
- </dependency>
自己管理jar包需要添加spring-security-taglibs-3.0.5.RELEASE.jar包及其依赖包。
异常:The absolute uri: http://www.springframework.org/security/tags cannot be resolved in either web.xml or the jar files deployed with this application的更多相关文章
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application问题解决方案参考
错误信息:The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the ...
- maven jstl The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
maven jstl 报错 HTTP Status 500 – Internal Server Error Type Exception Report Message The absolute uri ...
- The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml or the jar files deployed with this application] with root cause异常处理及解释
1.问题描述: 在web的jsp文件中想用jstl这个标准库,在运行的时候很自然的引用jar包如下: <dependency> <groupId>javax.servlet.j ...
- exception The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml or the jar files deployed with this application
1.情景展示 eclipse,运行web项目时,报错信息如下: The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be ...
- org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
编程中遇到:org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot ...
- HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application 错误
解决方法链接:http://stackoverflow.com/questions/17709076/http-status-500-the-absolute-uri-http-java-sun-co ...
- HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
j 今天下午一直报这个问题,google了半天没有找到答案.百度了下,说是 tomcat的 lib文件夹下缺少jstl1.2,因为项目里面用的也是 jstl1.2和 standard-1.1.2.ja ...
- This absolute uri http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
部署生产环境出现以上错误,原因是jsp页面中使用了jstl的标签,但没有导入相应的jar包.因为开发环境 myeclipse10 自带类库已经集成 解决方法 ①将jstl.jar和standard.j ...
- The absolute uri: http://struts.apache.org/tags-bean cannot be resolved in either web.xml or the jar files deployed with this application
在一个tomcat中部署了一个struts-1.3.10的web项目,但是没有吧struts-1.3.10的lib中的jar包放进tomcat/lib中,所以导致了这个错误(访问该项目的页面时)
随机推荐
- js中模仿接口继承
一般情况下我们会这样写,但是这样写的话,不够美化或者直观. 如果我们可以这样写的话,感觉更好: 但是样子的话,我们没有考虑原型覆盖之类的,因为我们通常的情况,我们继承只有一层,在通常情况下,我们原型覆 ...
- js回调
请先看着一片blog: http://www.jb51.net/article/53027.htm 回调的两种使用方法: 1.一般的传函数.2.匿名函数 3.使用回调函数再使用call方法. 判断一个 ...
- DOM学习笔记(思维导图)
导图
- WEB前端开发规范
WEB前端开发规范 规范目的 为提高团队协作效率, 便于后台人员添加功能及前端后期优化维护, 输出高质量的文档, 特制订此文档.本文档如有不对或者不合适的地方请及时提出, 经讨论决定后方可更改. 基本 ...
- 如何在VMWare Workstation实现虚拟机与真机的文件共享
1.进入虚拟机的配置选项 进入方法有三种,一种是使用快捷键Ctrl+D,第二种是先右键点击虚拟机再选择Settings选项,第三种是点击快捷栏中的VM后选择Settings选项,后两种方法的截图如下. ...
- hibernate事务
hibernate事务 9.3 Hibernate的事务管理 事务(Transaction)是工作中的基本逻辑单位,可以用于确保数据库能够被正确修改,避免数据只修改了一部分而导致数据不完整,或者在修改 ...
- ORACLE建表练习
1,学生表 -- Create table create table T_HQ_XS ( xueh ) not null, xingm ) not null, xingb ) ', nianl NUM ...
- Js-字符转换数字
s 字符串转化成数字 的 三种方法主要有 转换函数.强制类型转换.利用js变量弱类型转换. 1. 转换函数: js提供了parseInt()和parseFloat()两个转换函数.前者把值转换成整数, ...
- 学习笔记-Kuaihu(仿知乎日报)
本文目的:由于第一次学习较为完整的项目,故作记录以系统地整理APP开发知识 先看看整个项目结构: activity, fragment, 不用说了.可以看做MVC中的controller db, 存储 ...
- 7、8上的cell上的一个按钮,当点击按钮时,要拿到这个cell,可以用代理,也可以用superview
/** cell上的付款按钮事件 */ - (IBAction)paymentButtonClick:(UIButton *)sender { /** * @author SongXing, 15-0 ...