`

apache-shiro杂记(三) 用了apache-shiro后,HttpSession.getServletContext() API无法正常工作了

阅读更多
用了apache-shiro以后,偶然发现servlet环境下(我开发时用的servlet3.0) HttpSession.getServletContext() 一直返回的是null
查看了ShiroHttpSession实现类的源代码,结合shiro官方文档。发现修改web.xml可以解决这个问题。

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
	version="3.0">

	<!-- apache-shiro 核心拦截器 -->
	<filter>
		<filter-name>shiroFilter</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
		<init-param>
			<param-name>targetFilterLifecycle</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>shiroFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
</web-app>


:)
分享到:
评论
2 楼 aib628 2015-09-14  
还想请教一个问题,在shiro下,如何可以像HttpServletSession一样可以在Spring启动时加入监听,以方便统计当前在线人数呢?
1 楼 aib628 2015-09-14  
楼主你好,这个问题可否详细一点,是什么原因造成的呢?只需要在web.xml里加入以上代码就可以解决问题么?

相关推荐

    apache-shiro-1-2-x-reference

    Apache Shiro是一个功能强大、灵活的开放式安全框架,干净利落地处理身份验证、授权、企业会话管理和加密。 Shiro可以帮助我们完成:认证、授权、加密、会话管理、与Web集成、缓存等。 【apache-shiro-1-2-x-...

    apache-shiro-1-2-x-reference.zip

    shiro官方文档(中文) apache-shiro-1-2-x-reference apache-shiro-1-2-x-reference

    Apache-Shiro-使用手册

    Apache-Shiro-使用手册 Apache Shiro 是一个框架,可用于身份验证和授权。本文提供了几个示例用来展示如何在 Java™ 应用程序中使用 Shiro 并给出了如何在一个 Grails web 应用程序中使用它的概述。

    apache-shiro-1.2.x-reference-中文文档

    apache-shiro-1.2.x-reference-中文文档

    shiro-crypto-hash-1.4.0-API文档-中文版.zip

    Maven坐标:org.apache.shiro:shiro-crypto-hash:1.4.0; 标签:apache、shiro、crypto、hash、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性...

    SpringMVC-Mybatis-Shiro-redis-master

    SpringMVC-Mybatis-Shiro-redis-master..............

    Apache-shiro使用手册

    apache-shiro中文开发技术手册,很实用

    thymeleaf-extras-shiro, 用于 Apache Shiro标记的Thymeleaf方言.zip

    thymeleaf-extras-shiro, 用于 Apache Shiro标记的Thymeleaf方言 thymeleaf-extras-shiro Shiro的Thymeleaf 方言, 。下载 Maven&lt;dependency&gt; &lt;groupId&gt;com.github.th

    Apache-Shiro反序列化1

    Apache-Shiro反序列化1

    Java模板引擎 thymeleaf-extras-shiro-1.0.2.jar

    如果要使用shiro的话,可以引入 thymeleaf-extras-shiro.jar这个拓展包来曲线实现shiro的前端验证

    Apache-shiro-1.7.0.zip下载

    老版本存在Shiro命令执行漏洞,使用漏洞工具测试,可以发送命令至服务器获得执行。需要升级最新的shiro文件。

    Apache-Shiro-中文参考文档.docx

    以下是你可以用 Apache Shiro 所做的事情: • 验证用户来核实他们的身份 • 对用户执行访问控制,如: • 判断用户是否被分配了一个确定的安全角色 • 判断用户是否被允许做某事 • 在任何环境下使用 Session API,...

    shiro-core-1.4.0-API文档-中文版.zip

    Maven坐标:org.apache.shiro:shiro-core:1.4.0; 标签:apache、shiro、core、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的...

    SpringMVC-Mybatis-Shiro-redis-0.2-master

    基于SpringMVC Mybatis Shiro Redis 的权限管理系统,该系统已经部署到线上,线上访问地址:http://shiro.itboy.net,登录账号:admin 密码:sojson,,详细教程参考sojson.com/shiro

    apache-shiro教程完整版.7z

    张开涛《跟我学Shiro》PDF原件版本,学习交流使用,带目录,清晰。

    shiro-cache-1.4.0-API文档-中英对照版.zip

    Maven坐标:org.apache.shiro:shiro-cache:1.4.0; 标签:apache、shiro、cache、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,...

    单点登录sso-shiro-cas-maven

    &lt;bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"&gt; &lt;!-- 设定用户的登录链接,这里为cas登录页面的链接地址可配置回调地址 --&gt; ${shiro.loginUrl}" /&gt; &lt;!-- ...

    apache-shiro-core-api

    apace shiro安全框架api,喜欢的童鞋下载吧

    apache-activemq-5.15.11-bin.tar.gz

    ActiveMQ 5.15.11 Linux版,

    shiro-crypto-hash-1.4.0-API文档-中英对照版.zip

    Maven坐标:org.apache.shiro:shiro-crypto-hash:1.4.0; 标签:apache、shiro、crypto、hash、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 ...

Global site tag (gtag.js) - Google Analytics