JSP中的表單
<formaction="login.action"method="post">
用戶名:<inputtype="text"name="username"/> <br/>
密碼: <inputtype="password"name="password"/><br/>
<inputtype="submit"value="登陸"/>
</form>
Action中的屬性
publicclassLoginActionextends ActionSupport {
private String username;
private String password;
public String getUsername() {
returnusername;
}
publicvoid setUsername(String username) {
this.username = username;
}
public String getPassword() {
returnpassword;
}
publicvoid setPassword(String password) {
this.password = password;
}
。。。。。。。。。。。。。。。
}
JSP中的表單
<formaction="login.action"method="post">
用戶名:<inputtype="text"name="user.username"/> <br/>
密碼: <inputtype="password"name="user.password"/><br/>
<inputtype="submit"value="登陸"/>
</form>
LoginAction中的屬性改為user
publicclassLoginActionextends ActionSupport{
private User user;
public User getUser() {
returnuser;
}
publicvoid setUser(User user) {
this.user = user;
}
Action類要實現一個泛型接口
JSP中的表單
<formaction="login.action"method="post">
用戶名:<inputtype="text"name="username"/> <br/>
密碼: <inputtype="password"name="password"/><br/>
<inputtype="submit"value="登陸"/>
</form>
publicclassLoginActionextends ActionSupport implements ModelDriven<User> {
private User user = new User();
public User getModel() {
returnuser;
}
}