
1注册

代码
码云:
1LoginController
2.UserService
3.pom.xml
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.51</version>
</dependency>
http://127.0.0.1:8080/reg?username=a&password=apwd

2.登陆/登出

登陆 用ticket来记录用户
Cookie:
try{
//ticket Cookie
Map<String,Object> map =userService.register(username,password);
if(map.containsKey("ticket")){
Cookie cookie = new Cookie("ticket",map.get("ticket").toString());
cookie.setPath("/");
//如果记住 当前用户
if(rember >0){
cookie.setMaxAge(3600*24*5);
}
response.addCookie(cookie);
return ToutiaoUtil.getJSONString(0,"注册成功");
}else{
return ToutiaoUtil.getJSONString(1,map);
}

3.页面访问


1万+

被折叠的 条评论
为什么被折叠?



