[英]java play 2.0 form not binding
有人知道為什么我的表格不綁定
這是我所擁有的
public class Account {
@Required
private String id = "";
...
}
controlers.Application.java中的表單
static Form<Account> accountForm = Form.form(Account.class);
with a method
public static Result addAccount() {
Form<Account> filledForm = accountForm.bindFromRequest();
if (filledForm.hasErrors()) {
...
...
和scala表單模板:
@form(action = routes.Application.addAccount()) {
@inputText(accountForm("id"))
<input type="submit" name="action" value="submit ID"/><br />
}
哦,路線定義為:
GET /createAccount controllers.Application.addAccount()
我打印了收到的數據,它獲取了id值並提交了操作。
我已經打印了所有驗證錯誤,並且似乎在id字段上只顯示error.required不知道是因為我輸入的地址行是:
/createAccount?id=1001&action=submit+ID
但是if語句hasErrors()總是結果為true
拜托-我明顯缺少什么嗎?
當您的bean具有私有字段時,您需要定義適當的java bean getter和setters(綁定是由SpringDataBinder完成的,需要這個)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.