日常提交

This commit is contained in:
wu xiangkai
2022-10-20 18:15:39 +08:00
parent 9aca3a3e1e
commit 28e6e75599

View File

@@ -142,6 +142,16 @@ byte[] encrypted =
cipherService.encrypt(fileBytes, testKey);
```
## Shiro框架的Web支持
### Web Session管理
对于web应用shiro默认情况下其session会使用已经存在的servlet容器session。当使用subject.getSession()或者subject.getSession(boolean)获取session实例时**Shiro将会返回一个基于Servlet容器的HttpSession实例来作为Session实例返回值**。
> 对于Shiro来说其业务层代码通过subject.getSession来获取Shiro Session实例即使当前运行于Servlet容器业务层代码在与Shiro Session交互时也不知道与其交互的是HttpSession。
> 故而在使用Shiro Session时其Session是独立与环境的Web应用和非Web应用都可以通过相同的Shiro Session API与Shiro Session进行交互而Shiro Session是否是基于Servlet容器的HttpSession用户是无感知的。
### Shiro Native Session
当启用Shiro Native Session之后对于Web应用如果想使用Shiro Session来代替基于Servlet容器的HttpSession无需修改HttpServletRequest.getSession()和HttpSession API为Shiro Session API。
Shiro Session完全实现了Servlet Session的标准以此支持Shiro Session在Web应用中的使用。在使用了Shiro Native Session后任何对HttpServletRequest和HttpSession API的调用都会被Shiro拦截