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来管理依赖包,只需添加下面依赖:

  1. <dependency>
  2. <groupId>org.springframework.security</groupId>
  3. <artifactId>spring-security-core</artifactId>
  4. <version>3.0.5.RELEASE</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.springframework.security</groupId>
  8. <artifactId>spring-security-web</artifactId>
  9. <version>3.0.5.RELEASE</version>
  10. </dependency>
  11. <dependency>
  12. <groupId>org.springframework.security</groupId>
  13. <artifactId>spring-security-config</artifactId>
  14. <version>3.0.5.RELEASE</version>
  15. </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之前,否则会出现如下错误:

  1. HTTP ERROR 404
  2. Problem accessing /Struts_Spring_Maven/spring_security_login. Reason:
  3. There is no Action mapped for namespace [/] and action name [spring_security_login] associated with context path [/Struts_Spring_Maven].

struts2和spring security配置如下:

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>
  4. classpath:applicationContext.xml
  5. /WEB-INF/applicationContext-security.xml
  6. </param-value>
  7. </context-param>
  8. <!-- 配置Struts中心过滤器 -->
  9. <filter>
  10. <filter-name>struts2</filter-name>
  11. <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  12. <init-param>
  13. <param-name>actionPackages</param-name>
  14. <param-value>zwh.struts.maven.action</param-value>
  15. </init-param>
  16. </filter>
  17. <!-- 配置spring security的过滤器 -->
  18. <filter>
  19. <filter-name>springSecurityFilterChain</filter-name>
  20. <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  21. </filter>
  22. <!-- spring security的filter-mapping一定要配置struts的前面 -->
  23. <filter-mapping>
  24. <filter-name>springSecurityFilterChain</filter-name>
  25. <url-pattern>/*</url-pattern>
  26. </filter-mapping>
  27. <!-- struts的filter-mapping -->
  28. <filter-mapping>
  29. <filter-name>struts2</filter-name>
  30. <url-pattern>/*</url-pattern>
  31. </filter-mapping>

3.添加applicationContext-security.xml文件,我是直接将示例项目中的文件直接拷贝到我的项目中去的,拷贝到WEB-INF目录下。文件内容如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans:beans xmlns="http://www.springframework.org/schema/security"
  3. xmlns:beans="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  6. http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
  7. <global-method-security pre-post-annotations="enabled">
  8. <!-- AspectJ pointcut expression that locates our "post" method and applies security that way
  9. <protect-pointcut expression="execution(* bigbank.*Service.post*(..))" access="ROLE_TELLER"/>
  10. -->
  11. </global-method-security>
  12. <http use-expressions="true">
  13. <intercept-url pattern="/secure/extreme/**" access="hasRole('ROLE_SUPERVISOR')"/>
  14. <intercept-url pattern="/secure/**" access="isAuthenticated()" />
  15. <!-- Disable web URI authorization, as we're using <global-method-security> and have @Secured the services layer instead
  16. <intercept-url pattern="/listAccounts.html" access="isRememberMe()" />
  17. <intercept-url pattern="/post.html" access="hasRole('ROLE_TELLER')" />
  18. -->
  19. <intercept-url pattern="/**" access="permitAll" />
  20. <form-login />
  21. <logout />
  22. <remember-me />
  23. <!--
  24. Uncomment to enable X509 client authentication support
  25. <x509 />
  26. -->
  27. <!-- Uncomment to limit the number of sessions a user can have -->
  28. <session-management invalid-session-url="/timeout.jsp">
  29. <concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
  30. </session-management>
  31. </http>
  32. <!--
  33. Usernames/Passwords are
  34. rod/koala
  35. dianne/emu
  36. scott/wombat
  37. peter/opal
  38. -->
  39. <authentication-manager>
  40. <authentication-provider>
  41. <password-encoder hash="md5"/>
  42. <user-service>
  43. <user name="rod" password="a564de63c2d0da68cf47586ee05984d7" authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" />
  44. <user name="dianne" password="65d15fe9156f9c4bbffd98085992a44e" authorities="ROLE_USER,ROLE_TELLER" />
  45. <user name="scott" password="2b58af6dddbd072ed27ffc86725d7d3a" authorities="ROLE_USER" />
  46. <user name="peter" password="22b5c9accc6e1ba628cedc63a72d57f8" authorities="ROLE_USER" />
  47. </user-service>
  48. </authentication-provider>
  49. </authentication-manager>
  50. </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.如果遇到如下问题:

  1. 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还需要添加如下依赖

  1. <dependency>
  2. <groupId>org.springframework.security</groupId>
  3. <artifactId>spring-security-taglibs</artifactId>
  4. <version>3.0.5.RELEASE</version>
  5. </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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

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

  8. 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 ...

  9. 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中,所以导致了这个错误(访问该项目的页面时)

随机推荐

  1. [USACO2005][POJ3169]Layout(差分约束)

    题目:http://poj.org/problem?id=3169 题意:给你一组不等式了,求满足的最小解 分析: 裸裸的差分约束. 总结一下差分约束: 1.“求最大值”:写成"<=& ...

  2. WCF 入门 (17)

    前言 看的是入门视频,就希望培养一个学习的习惯吧. 前段时间看了微软的SurfaceBook的视频,被惊艳到了,但是我没钱买啊... 第17集 WCF中未经处理的异常 Unhandled except ...

  3. 第五章:javascript:队列

    队列是一种列表,不同的是队列只能在末尾插入元素,在队首删除元素.队列用于存储按顺序排列的数据.先进先出.这点和栈不一样,在栈中,最后入栈的元素反被优先处理.可以将队列想象成银行排队办理业务的人,排队在 ...

  4. JS事件学习笔记(思维导图)

    导图

  5. 【Moqui业务逻辑翻译系列】Sales Representative Seeks Prospects and Opportunities 销售代表寻找期望合作对象和机会

    h1. Sales Representative Seeks Prospects and Opportunities 销售代表寻找期望合作对象和合作机会 h4. Ideas to incorporat ...

  6. 今天学习到的关于mysql数据库的linux命令

    1. 登录mysql数据库: mysql -uroot -p 2.安装会提示的mysql的数据库软件:mycli sudo apt-get install mycli 3.安装依赖包: sudo ap ...

  7. 修改Oracle最大连接数

    1.修改Oracle最大连接数的方法 http://my.oschina.net/shootercn/blog/11193 a.以sysdba身份登陆PL/SQL 或者 Worksheet sqlpl ...

  8. js阻止表单重复提交

    //校验表单的数据 function newFatherModuleVerify() { var moduelName = $('#fatherModule_moduelName').val(); a ...

  9. 项目总结—jQuery EasyUI-DataGrid动态加载表头

    http://blog.csdn.net/zwk626542417/article/details/19248747 概要 在前面两篇文章中,我们已经介绍了在jQuery EasyUI-DataGri ...

  10. VS2012变化的快捷键:

    VS2012变化的快捷键: 注释::VS2010是(Ctrl+E,C),VS2012是(Ctrl+K, Ctrl+C),实际操作,按住Ctrl键不放,先按K键,再按C键.相当于Ctrl+K加 Ctrl ...