IK.AM

@making's tech note


Remove 'jsessionid=xxxx' from URL in Spring Boot App

🗃 {Programming/Java/org/springframework/boot}
🏷 Java 🏷 Spring Boot 
🗓 Updated at 2015-09-22T11:03:55Z  🗓 Created at 2015-09-22T11:03:55Z   🌎 English Page

Add the following configuration to your JavaConfig:

@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

<session-config>
    <tracking-mode>COOKIE</tracking-mode>
</session-config>

in web.xml

Postscript 2015-10-04

Awesome!


✒️️ Edit  ⏰ History  🗑 Delete