Spring boot 去除URL 里的 JSESSIONID
2024-10-21 15:59:13
方法一 application.yml 里设置
server:
port: 80
servlet:
session:
tracking-modes: cookie
cookie:
http-only: true
方法二 启动类继承SpringBootServletInitializer 类,重写 onStartup 方法
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import java.util.Collections;
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class NdaDemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(NdaDemoApplication.class, args);
}
public void onStartup(ServletContext servletContext)throws ServletException {
super.onStartup(servletContext);
servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
sessionCookieConfig.setHttpOnly(true);
}
}
最新文章
- JAVA集合
- Linux 磁盘自检介绍
- ElasticSearch 入门笔记1
- C#路径 (转载)
- SWFUpload下载地址
- Jersey Restful部署到Tomcat注意事项
- 非原生APP开发中可以用到的JQ插件
- HDU 1228 A + B 浙江大学研究生冠军
- 1.1XAF框架开发视频教程-简单的订单管理实现过程,视频,提纲,及教程源码
- java常见文件操作
- GoldenGate 复制进程报错";OGG-01296 Error mapping";,丢弃文件报错“Mapping problem with delete record (target format)”,且实际条目存在
- JS中call,apply,bind方法的总结
- ●HDU 3689 Infinite monkey theorem
- 数据结构之Trie树
- [orleans2.1]这是你没玩过的船新版本
- LogHelper 日志
- SSH(poderosa)を使って、さくらのMySQLサーバーに接続する方法
- Python文本处理
- ElasticSearch 分组查询的几个例子
- $Django 客户端->;wsgi->;中间组件->;urls->;views(model,template) 总结+补充(事物,choices,inclusion_tag)!
热门文章
- ubuntu-网络配置文件
- edgex0.7.1_1.0.1的X86编译和交叉编译
- Andrew Ng机器学习 四:Neural Networks Learning
- APS实现的要点与难点
- CentOS7怎样安装Jenkins
- SourceTree&;Git -01 -代码拉取推送流程 -提交时的相关注意事项
- 1216 Vue基础
- 《3+1团队》【Beta】Scrum meeting 3
- js与jquery中html() text() val()中的区别
- Spring源码窥探之:xxxAware接口