src/com/rain/controller/UserController.java
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.rain.controller;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.rain.domain.Employee;
import com.rain.domain.Job;
import com.rain.domain.Notice;
import com.rain.domain.User;
import com.rain.service.RainService;
import com.rain.util.common.Constants;
@Controller
public class UserController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/user/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("/user/list");
return mv;
}
// 退出功能
@RequestMapping(value="/user/logout")
public ModelAndView logout(ModelAndView mv, HttpSession session){
session.setAttribute(Constants.USER_SESSION, null);
session.setAttribute("tip", null);
mv.setViewName("redirect:/index");
return mv;
}
@RequestMapping(value="/login")
public ModelAndView login(@RequestParam("loginname") String loginname,
@RequestParam("password") String password,@RequestParam("tip") String tip,
HttpSession session,
ModelAndView mv){
// 调用业务逻辑组件判断用户是否可以登录
boolean flag = false;
if("1".equals(tip)) {
User user = rainservice.login(loginname, password);
if(user!=null){
// 将用户保存到HttpSession当中
System.out.println("HttpSession");
session.setAttribute(Constants.USER_SESSION, user);
session.setAttribute("tip", "1");
// 客户端跳转到main页面
mv.setViewName("redirect:/index");
后面还有 88 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
