src/com/marry/controller/LogController.java
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.marry.controller;
import com.marry.entity.User;
import com.marry.service.UserService;
import com.marry.util.RandomCodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;
@Controller
@RequestMapping("log")
public class LogController {
@Autowired
private UserService userService;
@RequestMapping("login")
public String login(String userName, String password, HttpSession session, Model model){
User user=userService.login(userName, password);
if (user!=null){
session.setAttribute("login",user);
if (user.getRole()==1){
return "redirect:/user/list";
}else {
return "redirect:/type/index";
}
}else {
model.addAttribute("error1","用户名或密码错误");
return "login";
}
}
@RequestMapping("reg")
public String reg(User user,Model model,String code,HttpSession session){
String codeTest= (String) session.getAttribute("code");
if (!code.equalsIgnoreCase(codeTest)){
model.addAttribute("error2","验证码错误!");
model.addAttribute("userName",user.getUserName());
return "login";
}
user.setRole(2);
userService.insert(user);
model.addAttribute("error1","注册成功!请登陆:");
return "login";
}
@RequestMapping("/getCode")
public void getCode(HttpSession session, HttpServletResponse response) throws IOException {
RandomCodeUtil code = new RandomCodeUtil();
BufferedImage bi = code.getImage();
String text = code.getText();
session.setAttribute("code", text);
code.output(bi,response.getOutputStream());
}
后面还有 13 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。