Security——禁用jsessionid

如果自定义登录流程,很可能会报错,提示url中间不允许出现 “;”。

因为系统老是自动拼接上jsessionid,这时候增加一个配置类即可。

import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Configuration;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.SessionTrackingMode;
import java.util.Collections;

/**
 * 禁用jsessionid
 *
 * @author Mr.css
 * @date 2022-01-06 18:34
 */
@Configuration
public class CustomServletContextInitializer implements ServletContextInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
    }
}

 

上一篇:springboot整合mybatis


下一篇:实例化Servlet类异常