去掉shiro登录时url里的JSESSIONID
来源:互联网 发布:excel怎么复制所有数据 编辑:程序博客网 时间:2024/05/20 13:04
看别人博客写的 主要是类型转换出错的 SecurityManager securityManager = getSecurityManager(); 下面已标红
package com.shiro.filter;import org.apache.shiro.web.servlet.ShiroHttpServletRequest;import org.apache.shiro.web.servlet.ShiroHttpServletResponse;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletResponse;/** * @author Yang * @create 2017-12-11 15:06 * 描述: */public class MyShiroHttpServletResponse extends ShiroHttpServletResponse { public MyShiroHttpServletResponse(HttpServletResponse wrapped, ServletContext context, ShiroHttpServletRequest request) { super(wrapped, context, request); } @Override protected String toEncoded(String url, String sessionId) { if ((url == null) || (sessionId == null)) return (url); String path = url; String query = ""; String anchor = ""; int question = url.indexOf('?'); if (question >= 0) { path = url.substring(0, question); query = url.substring(question); } int pound = path.indexOf('#'); if (pound >= 0) { anchor = path.substring(pound); path = path.substring(0, pound); } StringBuilder sb = new StringBuilder(path); //重写toEncoded方法,注释掉这几行代码就不会再生成JESSIONID了。 // if (sb.length() > 0) { // session id param can't be first. // sb.append(";"); // sb.append(DEFAULT_SESSION_ID_PARAMETER_NAME); // sb.append("="); // sb.append(sessionId); // } sb.append(anchor); sb.append(query); return (sb.toString()); }}
package com.shiro.filter;import org.apache.shiro.mgt.SecurityManager;import org.apache.shiro.spring.web.ShiroFilterFactoryBean;import org.apache.shiro.web.filter.mgt.FilterChainManager;import org.apache.shiro.web.filter.mgt.FilterChainResolver;import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;import org.apache.shiro.web.mgt.WebSecurityManager;import org.apache.shiro.web.servlet.AbstractShiroFilter;import org.apache.shiro.web.servlet.ShiroHttpServletRequest;import org.springframework.beans.factory.BeanInitializationException;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletResponse;/** * @author Yang * @create 2017-12-11 15:08 * 描述: */public class MyShiroFilterFactoryBean extends ShiroFilterFactoryBean { @Override public Class getObjectType() { return MySpringShiroFilter.class; } @Override public SecurityManager getSecurityManager() { return super.getSecurityManager(); } @Override protected AbstractShiroFilter createInstance() throws Exception { SecurityManager securityManager = getSecurityManager(); if (securityManager == null) { String msg = "SecurityManager property must be set."; throw new BeanInitializationException(msg); } if (!(securityManager instanceof WebSecurityManager)) { String msg = "The security manager does not implement the WebSecurityManager interface."; throw new BeanInitializationException(msg); } FilterChainManager manager = createFilterChainManager(); PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver(); chainResolver.setFilterChainManager(manager); return new MySpringShiroFilter((WebSecurityManager) securityManager, chainResolver); } private static final class MySpringShiroFilter extends AbstractShiroFilter { protected MySpringShiroFilter(WebSecurityManager webSecurityManager, FilterChainResolver resolver) { super(); if (webSecurityManager == null) { throw new IllegalArgumentException("WebSecurityManager property cannot be null."); } setSecurityManager(webSecurityManager); if (resolver != null) { setFilterChainResolver(resolver); } } @Override protected ServletResponse wrapServletResponse(HttpServletResponse orig, ShiroHttpServletRequest request) { return new MyShiroHttpServletResponse(orig, getServletContext(), request); } }}<!--<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">--><bean id="shiroFilter" class="com.shiro.filter.MyShiroFilterFactoryBean"> <!-- 权限管理器 --> <property name="securityManager" ref="securityManager"/>...
</bean>
阅读全文
1 0
- 去掉shiro登录时url里的JSESSIONID
- 去掉shiro登录时url里的JSESSIONID
- 去掉shiro登录时url里的JSESSIONID
- Apache Shiro去掉URL中的JSESSIONID
- Apache Shiro去掉URL中的JSESSIONID
- 去掉url 后面的jsessionid
- 去掉 URL 中讨厌的 jsessionid
- Java去掉 URL 中的 jsessionid
- shiro重定向时URL中的JSESSIONID问题
- Spring boot中去掉URL后面的jsessionid
- AngularJS去掉的URL里的#号
- AngularJS去掉的URL里的#号
- AngularJS去掉的URL里的#号
- AngularJS去掉的URL里的#号
- php 去掉Url里的 index.php
- thinkphp5 去掉url里的index.php
- 去掉静态文件后面的jsessionid
- 安全框架Shiro获取登录前的URI URL
- 7-10(图) 旅游规划
- scipy.spatial 距离计算模块
- python文件打开方式
- nfs和iscsi target
- joda-time的使用
- 去掉shiro登录时url里的JSESSIONID
- [知了堂学习笔记] java_入门
- 《看透springMVC源码》之Connector分析
- linux下tomcat开机自启
- crontab 计划任务
- 卷积神经网络CNN讲解
- 理解运算符的操作
- 监控Java对象回收的原理与实现
- 哈尔滨理工大学第七届程序设计竞赛决赛(网络赛-低年级组)【solved:10 / 10】