-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAction.java
More file actions
56 lines (39 loc) · 991 Bytes
/
UserAction.java
File metadata and controls
56 lines (39 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package action;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import model.User;
import service.UserService;
@Controller
public class UserAction {
@Autowired
private UserService ser;
//转到login.jsp页面
@RequestMapping("/login.html")
public String toLogin(){
return "login";
}
//登录
@RequestMapping("/login.action")
public String doLogin(User user,HttpSession session) {
if(user !=null){
User findUser = ser.findByUsername(user);
if(findUser !=null){
//匹配密码
if(findUser.getPassword().equals(user.getPassword())){
//放入session中
session.setAttribute("sessionUser", findUser);
return "index";
}
}
}
return "login";
}
public UserService getSer() {
return ser;
}
public void setSer(UserService ser) {
this.ser = ser;
}
}