Set tracking mode to cookie to remove appended session id, without using web.xml

前端 未结 4 1541
失恋的感觉
失恋的感觉 2020-12-29 16:43

I am setting up a completely java based spring app with no xml config :

public class WebApp extends AbstractAnnotationConfigDispatcherServletInitializer {
           


        
4条回答
  •  攒了一身酷
    2020-12-29 17:04

    you can do it as in below

    public class WebConfig implements WebApplicationInitializer {
    
        @Override
        public void onStartup(ServletContext servletContext)
                throws ServletException {
            HashSet set = new HashSet();
            set.add(SessionTrackingMode.COOKIE);
            servletContext.setSessionTrackingModes(set);
    
        }
    
    }
    

提交回复
热议问题