日期:2014-05-18 浏览次数:20595 次
public class Treasure implements java.io.Serializable {
// Fields
private String temail;
private String tpass;
public Treasure() {
}
public String getTemail() {
return this.temail;
}
public void setTemail(String temail) {
this.temail = temail;
}
public String getTpass() {
return this.tpass;
}
public void setTpass(String tpass) {
this.tpass = tpass;
}
}
public class Bacis extends ActionSupport {
private static final long serialVersionUID = 1L;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
DateSource ds = null;
Verification vf = new Verification();
private Treasure t; //这里是实力了上面那个类 然后下面是get set这个类 我看官网上是这么写的 不过不知道我领悟的对不对
public void setTreasure(Treasure t) {
this.t = t;
}
public Treasure getTreasure() {
return t;
}
public String execute() throws Exception{
return null;
}
/**
* 登录(程序是走了这个方法 .. )
*/
public String login() throws Exception{
String temail = null;
String tpass = null;
/**
* 链接数据池
*/
ds = new DateSource();
try {
con = ds.getDate();
} catch ( Exception e ) {
e.printStackTrace();
}
//获得前台数据
try {
temail = getTreasure().getTemail(); //这里想获得前台form的值 可是为空
tpass = getTreasure().getTpass();
} catch ( NullPointerException npe ) {
npe.printStackTrace();
}
return SUCCESS;
}
}
<form action="login.action" method="POST">
用户名:<input type="text" name="temail"><br>
密码:<input type="text" name="tpass"><br>
<input type="submit" value="登录">
</form>
<form action="login.action" method="POST">
用户名:<input type="text" name="t.temail"><br>