2016-05-13 39 views
0

我試圖通過型動物形成價值觀與目標參數像這樣的控制器:Spring MVC的Thymeleaf:Object參數屬性值總是空

在我看來

我:

<form id="line_form" action="#" th:object="${lineFilter}" method="post"> 
<input type="text" id="nameHolder" th:field="*{msisdn}"> 
<input type="text" id="nameHolder" th:field="*{nameHolder}"> 
... 
</form> 

而在我的控制,我這個方法:

@ResponseBody 
@RequestMapping(value = "/listFilteredByAccount", produces = MediaType.APPLICATION_JSON_VALUE) 
public DatatablesResponse<LineVO> getLineFilteredListWithAccount(LineFilter lineFilter, @DatatablesParams DatatablesCriterias criterias, Model model, Locale locale, HttpServletRequest req, String entity) 

在我的方法控制,lineFilter領域始終是空 我也可以調用以前的方法與按鈕

而且,網址是這樣叫的dataTable中:

dt:url="@{/orders/listFilteredByAccount}" 

的設置領域的良好價值觀是什麼我已經忘了嗎?

我使用Thymeleaf與Spring MVC

回答

0

嘗試在你的控制器方法使用@ModelAttribute

public DatatablesResponse<LineVO> getLineFilteredListWithAccount(@ModelAttribute("lineFilter") LineFilter lineFilter, ..and the rest of your params...) 

設置你的表單動作,因爲你th:action="@{/orders/listFilteredByAccount}"

嘗試添加以下內容到控制器@RequestMapping(method = RequestMethod.POST, ...)」在你的表單中重新發帖。