@RequestMapping(value= "/redirect", method=RequestMethod.GET)
public String redirect()
{
return "redirect:onLogin";
}
如何将控件重定向回主页?用于检索管理主页的上述代码无效。
答案 0 :(得分:0)
这应该有效:
@RequestMapping(value= "/redirect", method=RequestMethod.GET)
public String redirect(){
return "redirect:/onLogin";
}
您还可以在重定向上传递参数以显示登录失败消息,如下所示:
@RequestMapping(value= "/redirect", method=RequestMethod.GET)
public String redirect(){
return "redirect:/onLogin?success=false";
}
然后在login.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:if test="${param.success eq false}">
<div class="alert alert-danger alert-dismissible">
<button class="close" aria-hidden="true" type="button" data-dismiss="alert">×</button>
<h4><i class="icon fa fa-ban"></i> Login Failed!</h4>
</div>
</c:if>