我正在尝试在spring MVC会话中存储登录的用户对象,并从jsp页面检索它。我在扩展CustomAuthenticationSuccessHandler
和SimpleUrlAuthenticationSuccessHandler
方法中创建了handle
,我在会话中存储了简单变量。
@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException {
String targetUrl ="/dashboard";
HttpSession session = request.getSession(true);
session.setAttribute("userEmail", "damith.uwu@gmail.com");
if (response.isCommitted()) {
System.out.println("Can't redirect");
return;
}
redirectStrategy.sendRedirect(request, response, targetUrl);
}
在我的jsp页面内
<c:if test="${not empty userEmail}">
${userEmail}
</c:if>
但它总是空着。
我的问题是,
谢谢。