---
title: Remove 'jsessionid=xxxx' from URL in Spring Boot App
tags: ["Java", "Spring Boot"]
categories: ["Programming", "Java", "org", "springframework", "boot"]
date: 2015-09-22T11:03:55Z
updated: 2015-10-04T01:58:31Z
---
Add the following configuration to your JavaConfig:
``` java
@Bean
ServletContextInitializer servletContextInitializer() {
// keep session only in cookie so that jsessionid is not appended to URL.
return servletContext -> servletContext.setSessionTrackingModes(
Collections.singleton(SessionTrackingMode.COOKIE));
}
```
This is equivalent to
``` xml
@nicolas_frankel With 1.3 there is a property: `server.session.tracking-modes=cookie`
— Phil Webb (@phillip_webb) 2015, 9月 25
Awesome!