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

其中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;
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值