邮件激活代码实现Servlce&Dao、登录功能代码分析

邮件激活代码实现Servlce&Dao

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// 获取激活码
String code = req.getParameter("code");
if (code!=null){
// 调用servlet完成激活
UserServlce servlce = new UserServlceImpl();
boolean b = servlce.active(code);

// 判断标记
String msg = null;
if (b){
msg="激活成功,请<a href='login.html'>登录</a>";
}else{
msg="激活失败,请联系管理员";
}
resp.setContentType("text/html;charset=utf-8");
resp.getWriter().write(msg);
}

}
}
    /**
* 根据激活码查询对象
*/
@Override
public User findByCode(String code) {
User user =null;
try {
String sql = "select * from tab_user where code = ?";
user = template.queryForObject(sql, new BeanPropertyRowMapper<User>(User.class), code);
} catch (DataAccessException e) {
e.printStackTrace();
}
return user;
}
/**
*修改指定用户激活状态
*/
@Override
public void updateStatus(User user) {
String sql = "update tab_user set status ='Y' where uid =?";
template.update(sql,user.getUid());
}
}

 

 

 

 

 

 

 

点击登录跳转登录页面

 

 

 

 

 

 

登录功能代码分析

 

 

 

posted @ 2022-08-26 11:03  一位程序袁  阅读(35)  评论(0编辑  收藏  举报