首页>代码>spring+spring mvc+hibernate+bootstrap开发小型物业管理系统>/物业管理系统/propertysystem/src/com/www/controller/index/LoginController.java
package com.www.controller.index;

import java.net.URLEncoder;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.www.entity.User;
import com.www.service.UserService;


@Controller
public class LoginController {
	@Resource
	private UserService userService;

	@RequestMapping(value = "/login")
	protected ModelAndView list(HttpServletRequest request,
			HttpServletResponse response,HttpSession  session) throws Exception {
		request.setCharacterEncoding("UTF-8");
		System.out.println("进来了?。。。。。");
		String name = request.getParameter("username");
		String pass = request.getParameter("password");
		System.out.println(name + ">>>>>>>>");
		System.out.println(pass + ">>>>>>>>");
		User user=userService.find(name, pass);
		if (user != null) {
			String type = user.getType();
			session.setAttribute("username",name);
			session.setAttribute("type",type);
			String username = URLEncoder.encode(name, "UTF-8");
			 Cookie cookiename = new Cookie("username", username );
			 Cookie cookiepass = new Cookie("pass", pass );
			 response.addCookie(cookiename);
			 response.addCookie(cookiepass);
			 if(type.equals("管理员")){
				 return	new ModelAndView("redirect:/user/list"); 
			 }else if(type.equals("维修人员")){
				 return	new ModelAndView("redirect:/repairtask/list");  
			 }
			 else if(type.equals("业主")){
				 return	new ModelAndView("redirect:/notice/show");  
			 }
			 else {
				 return	new ModelAndView("redirect:/repairtask/listreport");  
			 }
		} else {
			return	new ModelAndView("login");
		}
		
	}

}
最近下载更多
YhXyHx523  LV6 4月13日
768881787  LV7 4月10日
A-sunny-day  LV4 2023年6月11日
张真狗  LV9 2023年6月10日
wangjiedashuaige  LV1 2023年3月1日
pangxiangdong  LV4 2023年1月23日
2385649653  LV7 2022年11月2日
oulingqiao  LV13 2022年10月20日
LYLHYC  LV5 2022年10月12日
17683946472  LV9 2022年7月3日
最近浏览更多
pangzhihui  LV12 4月22日
YhXyHx523  LV6 4月13日
768881787  LV7 4月10日
zhangxiyu  LV3 3月26日
eagerwujin  LV4 3月2日
OMITUUID  LV6 2月26日
jiyun2021  LV9 1月24日
linXH_AiMo  LV2 1月19日
lilong007  LV20 2023年12月30日
iiiiiiixiiiiii  LV1 2023年12月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友