1
我正在以Content-Type
作爲application/x-www-form-urlencoded
發出PUT請求。我無法將表單主體元素映射到我的ModelDriven動作類(User
)。在strut中爲PUT請求驅動的模型問題?
下面是一個示例請求:
PUT:http://www.xyz.com/account/22424?userName=xyz&[email protected]
內容類型:應用/ X WWW的窗體-urlencoded
下面是代碼:
1)模型驅動動作類別:
public class User {
private String email;
private String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
2)控制器:
public class AccountController implements ModelDriven <User> {
private String id;
private User user = new User();
public String update() {
user.getUserName(); // Fails, returns NULL. (Expected "xyz")
}
public User getModel() {
return user;
}
}
任何建議表示讚賞。