主题 : freemarker使用session问题
级别: 秀才
UID: 12994
积分:68 加为好友
威望: 3 精华: 0
主题:7 回复:41
注册时间:2010-12-01
在线时长:0
1#   发表于:2011-06-04 10:31:41  IP:112.116.*.*
第一问题:
public Authentication login(String username, String password, String ip,
HttpServletRequest request, HttpServletResponse response,
SessionProvider session) throws UsernameNotFoundException,
BadCredentialsException {
UnifiedUser user = unifiedUserMng.login(username, password, ip);
Authentication auth = new Authentication();
auth.setUid(user.getId());
auth.setUsername(user.getUsername());
auth.setEmail(user.getEmail());
auth.setLoginIp(ip);
save(auth);
session.setAttribute(request, response, AUTH_KEY, auth.getId());
return auth;
}
登录时使用了上面这个方法。页面的user [#if user??]是怎么来了?

第二问题:
request.getSession().setAttribute("user", user);
我手动在session里添加值,为什么我在页面上取不到session的值呢?
 [#if user??]这个判断user为空。

求解。。。
级别: 童生
UID: 17664
积分:25 加为好友
威望: 0 精华: 0
主题:3 回复:21
注册时间:2011-04-05
在线时长:0
2#   发表于:2011-06-04 18:56:40  IP:113.198.*.*
在 frontUtils里面
<a href="http://www.xiangw.com" target="_blank" style="text-decoration:underline;font-size:13px;" title="襄阳网">http://www.xiangw.com</a>
1 共1页