我想手动重定向spring的logOut,如果用户logOuts需要保存日期 但我不能重定向它。
我的spring-security.xml如下:
<security:logout invalidate-session="true" logout-success-url="/login?logout=1" delete- cookies="JSESSIONID"/>
我的jsp页面:
<spring:url var="logoutUrl" value="/j_spring_security_logout" />
<li><a id="button" href="${logoutUrl}">Logout</a></li>
然后我想检查注销参数,如:
RequestMapping(value = "/login", method = RequestMethod.GET)
public String getLoginForm(@ModelAttribute("user") User user, Model model,@RequestParam(value = "logout", required = false) String logout)
{
{
try {
log.info("Opening Login page");
model.addAttribute("org.springframework.validation.BindingResult.user", model.asMap().get("addUserForm"));
ModelAndView modelAndView = new ModelAndView();
if (logout != null) {//logout is always null
//save date
modelAndView.addObject("msg", "You've been logged out successfully.");
}
} catch (Exception er) {
log.error("Error in opening Login page" + er);
}
return "/login";
}