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代码

浙公网安备 33010602011771号