File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package info .xiaomo .website ;
22
3- import info .xiaomo .website .interceptor .LoginInterceptor ;
43import org .springframework .boot .SpringApplication ;
54import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
65import org .springframework .boot .autoconfigure .domain .EntityScan ;
109import org .springframework .data .jpa .repository .config .EnableJpaRepositories ;
1110import org .springframework .stereotype .Controller ;
1211import org .springframework .transaction .annotation .EnableTransactionManagement ;
13- import org .springframework .web .servlet .config .annotation .InterceptorRegistry ;
1412import org .springframework .web .servlet .config .annotation .WebMvcConfigurerAdapter ;
1513
1614/**
@@ -41,12 +39,13 @@ public static void main(String[] args) throws Exception {
4139 SpringApplication .run (XiaomoMain .class , args );
4240 }
4341
44- /**
45- * 配置拦截器
46- */
47- public void addInterceptors (InterceptorRegistry registry ) {
48- registry .addInterceptor (new LoginInterceptor ()).addPathPatterns ("/" , "/web/**" );
49- super .addInterceptors (registry );
50- }
42+ // /**
43+ // * fixme 不要删
44+ // * 配置拦截器(前台暂时用不上拦截器,先注掉)
45+ // */
46+ // public void addInterceptors(InterceptorRegistry registry) {
47+ // registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/", "/web/**");
48+ // super.addInterceptors(registry);
49+ // }
5150
5251}
Original file line number Diff line number Diff line change @@ -253,4 +253,18 @@ public String validateEmail(
253253 session .setAttribute ("currentUser" , userModel );
254254 return UserView .INDEX .getName ();
255255 }
256+
257+ /**
258+ * 登出
259+ * @param session session
260+ * @return index
261+ */
262+ @ RequestMapping (value = "/logout" ,method = RequestMethod .GET )
263+ public String logout (HttpSession session ){
264+ UserModel userModel = (UserModel )session .getAttribute ("currentUser" );
265+ if (userModel !=null ){
266+ session .setAttribute ("currentUser" ,null );
267+ }
268+ return UserView .INDEX .getName ();
269+ }
256270}
You can’t perform that action at this time.
0 commit comments