zoukankan      html  css  js  c++  java
  • 4.30 记录

    1、社团信息以及进行用户信息分类

    2、完成情况

    社团信息录入存储功能完成,用户信息分类社长社员完成社长信息修改。

    package com.atguigu.crud.controller;

    import org.springframework.beans.factory.annotation.Autowired;


    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;

    import com.atguigu.crud.bean.Club;
    import com.atguigu.crud.bean.User;
    import com.atguigu.crud.service.ClubService;
    import com.atguigu.crud.service.UserService;
    import com.atguigu.crud.utils.ValidateCodeExpiredException;

    import java.util.List;

    import javax.mail.MessagingException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;

    @Controller
    public class MainController {

    @Autowired
    UserService userService;
    @Autowired
    ClubService club;

    @RequestMapping(value = { "/register" })
    public String doregister(User user, HttpServletRequest request) {
    // 获取请求的ip地址
    user.setRegister_ip(request.getRemoteAddr());
    boolean result = false;
    try {
    result = userService.register(user);
    request.setAttribute("msg", "注册成功");
    } catch (MessagingException e) {
    e.printStackTrace();
    request.setAttribute("msg", "注册失败");
    }
    return "forward:/register.jsp";
    }

    @RequestMapping("/login")
    public String dologin(String login_mail, String pwd, Model model, HttpSession session) {
    User user = userService.login(login_mail, pwd);
    if (user == null) {
    model.addAttribute("msg", "用户名或密码错误");
    } else {
    if (user.getStatus() == 0) {
    model.addAttribute("msg", "需激活|" + user.getId());
    } else {
    session.setAttribute("user", user);
    List<Club> list = club.list(user.getId());
    session.setAttribute("clublist", list);
    if (user.getNick_name() == null) {
    return "redirect:/user/edit?action=xiu";
    }
    return "forward:/index.jsp";
    }
    }
    return "forward:/login.jsp";
    }


    @GetMapping(value = "/active", produces = { "application/json;charset=UTF-8" })
    @ResponseBody
    public String active(Long userId, String code) {
    try {
    boolean result = userService.active(userId, code);
    if (result) {
    return "激活成功!";
    } else {
    return "验证码错误,请重新去邮箱确认";
    }
    } catch (ValidateCodeExpiredException e) {
    return e.getMessage();
    }
    }

    @GetMapping("/logout.html")
    public String logout(HttpSession session) {
    session.invalidate();
    return "redirect:/login.jsp";
    }
    }

    3、明日任务

    完善各个身份人愿信息填写时的输入限制

  • 相关阅读:
    Jquery+Ajax+Bootstrap Paginator实现分页的拼接
    推荐一款在线工具-程序员的工具箱
    推荐一款在线工具-程序员的工具箱
    Jquery+Ajax+Bootstrap Paginator实现分页的拼接
    JSP 基础语法
    jsp九大内置对象及四个作用域
    jdk 版本不一致导致的错误
    java虚拟机内存模型
    java 内存简介
    B2C
  • 原文地址:https://www.cnblogs.com/lx06/p/14761037.html
Copyright © 2011-2022 走看看