其中getUserByAccess是action中的一个方法 <form action="UserAction!getUserByAccess.action" method="post">
<input type="text" name="context"><br>
<input type="text" name="password"><br>
<input type="submit"
value="提交">
<td>${u3.UName}</td>
<body>
<td>${u3.UName}</td>
</body>
</form>
package com.twj.action;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.Result;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Scope;import org.springframework.stereotype.Component;import com.twj.base.BaseAction;import com.twj.entity.User;import com.twj.service.UserService;@Scope("prototype")@Component@Action(value="UserAction",results={ @Result(name="getUser",location="/index.jsp") ,@Result(name="getUserByAccess",location="/index.jsp")})public class UserAction extends BaseAction {@Autowiredprivate UserService userService;private User u;private User u2;private User u3;public User getU3() { return u3;}public void setU3(User u3) { this.u3 = u3;}private String name; private int i; public String getUser(){ u=userService.getUserById(1); return "getUser"; }public String getUserByName(){ //u2=userService.getUserByName(name); return "getUserByName";};private String context,password;public String getUserByAccess(){ System.out.println(context); u3=userService.getUserByAccess(context, password); System.out.println("-----------------"+context+password); return "getUserByAccess";}public User getU2() { return u2;}public void setU2(User u2) { this.u2 = u2;} public int getI() { return i;}public String getName() { return name;}public void setName(String name) { this.name = name;}public void setI(int i) { this.i = i;}public UserService getUserService() { return userService;}public void setUserService(UserService userService) { this.userService = userService;}public User getU() { return u;}public void setU(User u) { this.u = u;}public String getContext() { return context;}public void setContext(String context) { this.context = context;}public String getPassword() { return password;}public void setPassword(String password) { this.password = password;}}
- 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
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net