• Java高级架构师(一)第25节:实现前端的业务登录等功能


    package com.sishuok.architecture1;
    
    import javax.servlet.http.Cookie;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    
    import com.sishuok.architecture1.customermgr.service.ICustomerService;
    import com.sishuok.architecture1.customermgr.vo.CustomerModel;
    
    @Controller
    @RequestMapping("/")
    public class LoginController {
    	@Autowired
    	private ICustomerService ics = null;
    	
    	@RequestMapping(value="/toLogin",method=RequestMethod.GET)
    	public String toLogin(){
    		return "login";
    	}
    	@RequestMapping(value="/login",method=RequestMethod.POST)
    	public String login(@RequestParam("customerId")String customerId
    			,@RequestParam("pwd")String pwd,HttpServletResponse response){
    		
    		if(customerId==null || customerId.trim().length()==0){
    			return "login";
    		}
    		ics.getByUuid(1);
    		CustomerModel cm = ics.getByCustomerId(customerId);
    		
    		if(cm==null || cm.getUuid()<=0){
    			return "login";
    		}
    		
    		Cookie c = new Cookie("MyLogin",cm.getUuid()+","+System.currentTimeMillis());
    		response.addCookie(c);
    		
    		return "redirect:/toIndex";
    	}
    }
    

    主要是关于登录界面的Java代码

  • 相关阅读:
    Python、Lua和Ruby比较——脚本语言大P.K.
    vim 设置默认显示行号
    C语言
    How To Add Swap on Ubuntu 14.04
    How To Install Apache Kafka on Ubuntu 14.04
    php的错误和异常处理
    md5sum
    大牛的博客
    【转】4G手机打电话为什么会断网 4G上网和通话不能并存原因分析
    【转】女人最想要的是什么
  • 原文地址:https://www.cnblogs.com/sunrunzhi/p/10144639.html
Copyright © 2020-2023  润新知