方法一 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);
}
}

Spring boot 去除URL 里的 JSESSIONID的更多相关文章

  1. spring boot 在eclipse里启动正常,但打包后启动不起来

    现象描述: spring boot 在eclipse里启动正常,但打包后启动不起来. 错误日志如下: D:\Project>java -jar MKKY_CMS.jar . ____ _ __ ...

  2. Spring Boot 定制URL匹配规则的方法

    事情的起源:有人问我,说编写了一个/hello访问路径,但是吧,不管是输入/hello还是/hello.html,还是/hello.xxx都能进行访问.当时我还以为他对代码进行处理了,后来发现不是,后 ...

  3. 75. Spring Boot 定制URL匹配规则【从零开始学Spring Boot】

    在之前有一篇文章说了,博客名称从原来的<从零开始学Spring Boot>更改为<Spring Boot常见异常汇总>,后来写了几篇文章之后发展,有些文章还是一些知识点,所以后 ...

  4. 去掉shiro登录时url里的JSESSIONID https://blog.csdn.net/aofavx/article/details/51701012

    经过查找论坛和分析源码,确认了是在ShiroHttpServletResponse里加上的. 因此继承ShiroHttpServletResponse类,覆盖相应方法,再重写 ShiroFilterF ...

  5. Spring Boot Admin 的使用 2

    http://blog.csdn.net/kinginblue/article/details/52132113 ******************************************* ...

  6. spring cloud: 升级到spring boot 2.x/Finchley.RELEASE遇到的坑

    spring boot2.x已经出来好一阵了,而且spring cloud 的最新Release版本Finchley.RELEASE,默认集成的就是spring boot 2.x,这几天将一个旧项目尝 ...

  7. 1.spring boot起步之Hello World【从零开始学Spring Boot】

    [视频&交流平台] àSpringBoot视频 http://study.163.com/course/introduction.htm?courseId=1004329008&utm ...

  8. Spring Boot 成长之路(一) 快速上手

    1.创建工程 利用IntelliJ IDEA新建一个Spring Boot项目的Web工程 2.查看初始化的spring boot项目 工程建好之后会出现如下的目录结构: 值得注意的第一件事是,整个项 ...

  9. 曹工谈Spring Boot:Spring boot中怎么进行外部化配置,一不留神摔一跤;一路debug,原来是我太年轻了

    spring boot中怎么进行外部化配置,一不留神摔一跤:一路debug,原来是我太年轻了 背景 我们公司这边,目前都是spring boot项目,没有引入spring cloud config,也 ...

随机推荐

  1. CentOS 7 - 安装PostgreSQL

    一,用yum安装PostgreSQL . 选择安装版本和服务器平台后,执行安装命令,例如我要安装是9.6版本,平台是CentOS 7. https://www.postgresql.org/downl ...

  2. mongodump

    mongodump工具是MongoDB提供的用来导出数据的工具,具体的用法参考官方文档:https://docs.mongodb.com/manual/reference/program/mongod ...

  3. 如何通过Restful API的方式读取SAP Commerce Cloud的Product Reference

    从SAP官网上找到api的说明: https://api.sap.com/api/commerce_services/resource api endpoint: /rest/v2/electroni ...

  4. linux时间格式

    date "+%Y-%m-%d %H:%M:%S" 2019-10-27 12:02:33

  5. Python学习日记(二) list操作

    l = ['a','b','c','d',1,2,[3,'e',4]] 1.list.append() 在list的结尾新增一个新的元素,没有返回值,但会修改原列表 l.append(5) print ...

  6. nginx编译安装之-./configure 参数详解

    参考官方文档 http://nginx.org/en/docs/configure.html --with开头的,默认是禁用的(没启动的,想使用的话需要在编译的时候加上) --without开头的,默 ...

  7. javax.servlet.ServletException: Circular view path [index]: would dispatch back to the current handler URL [/pay/index] again. Check your ViewResolver setup!

    2019-08-08 17:12:03.544 ERROR 13748 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Se ...

  8. rocketmq那些事儿之入门基础

    分布式消息队列中间件作为高并发系统的核心组件之一,能够帮助业务系统解构提升开发效率和系统稳定性,其复杂性可见一斑,作为核心组件,有必要去深入了解学习 前言 分布式消息队列中间件主要具有以下优势: 削峰 ...

  9. 《CoderXiaoban》第九次团队作业:Beta冲刺与验收准备2

    项目 内容 这个作业属于哪个课程 任课教师博客主页链接 这个作业的要求在哪里 实验十三 团队作业9:BETA冲刺与团队项目验收 团队名称 Coderxiaoban团队 作业学习目标 (1)掌握软件黑盒 ...

  10. Ecshop漏洞通杀0day【最新入侵手法】

    昨晚上翻阅一本技术书籍中,找到灵感,发现的ECshop漏洞. 搜索关键字:关键字:powered by ecshop 方法一: 普通代码: user.php?act=order_query&o ...