NutzCN Logo
问答 添加发送验证邮件的方法相关错误
发布于 2844天前 作者 taobo0310 1412 次浏览 复制 上一个帖子 下一个帖子
标签:

@At("/active/mail")
@POST
public Object activeMail(@Attr(scope=Scope.SESSION, value="me")int userId,
HttpServletRequest req) {
NutMap re = new NutMap();
UserProfile profile = get(userId);
if (Strings.isBlank(profile.getEmail())) {
return re.setv("ok", false).setv("msg", "你还没有填邮箱啊!");
}
String token = String.format("%s,%s,%s", userId, profile.getEmail(), System.currentTimeMillis());
token = Toolkit._3DES_encode(emailKEY, token.getBytes());
String url = req.getRequestURL() + "?token=" + token;
String html = "如果无法点击,请拷贝一下链接到浏览器中打开验证链接 %s";
html = String.format(html, url, url);
try {
boolean ok = emailService.send(profile.getEmail(), "XXX 验证邮件 by Nutzbook", html);
if (!ok) {
return re.setv("ok", false).setv("msg", "发送失败");
}
} catch (Throwable e) {
log.debug("发送邮件失败", e);
return re.setv("ok", false).setv("msg", "发送失败");
}
return re.setv("ok", true);
}
这段代码里的:UserProfile profile = get(userId);提示错误
The method get(int) is undefined for the type UserModule
这个应该如何处理

3 回复

dao.fetch一下即可

来自炫酷的 NutzCN

改成如下:
UserProfile profile = dao.fetch(UserProfile.class,userId);
就可以了。谢谢

我得改改nutzbook里面代码...

添加回复
请先登陆
回到顶部