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));
    }
}

 

posted on 2022-01-07 09:26  疯狂的妞妞  阅读(485)  评论(0编辑  收藏  举报

导航