您的位置:首页 > Web前端 > JavaScript

jsp中form表单绑定action中的方法

2016-05-22 21:51 405 查看
其中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 {
@Autowired
private 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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: