之前做淘淘商城时有个小问题是单点登录系统的安全退出问题,怎么才能在点击 【退出】 时,跳转到主页面,也就是localhost:8082。其实很简单,就是在写controller时,返回一个跳转页面的字符串,如下面的代码:
@RequestMapping("/user/logout/{token}")
public String userLogout(@PathVariable String token) {
try {
TaotaoResult result = userService.userLogout(token);
} catch (Exception e) {
e.printStackTrace();
return TaotaoResult.build(500, ExceptionUtil.getStackTrace(e));
}
return "redirect:http://localhost:8082";
}
这里的redirect:http://localhost:8082就是跳转到商城主页面的意思。