lundi 23 février 2015

getting form:options value in AJAX

Jsp code is as follows:



<form:select id="taxId" path="taxSeqNo" cssClass="defaultText" <form:options items="${taxListItemsBean.taxList}" itemValue="key" itemLabel="label"/>
</form:select>


Where ${taxListItemsBean.taxList} is declared as



private List<KeyItemDto> taxList;


in the form.java class.


I want to pass this taxList through ajax to controller. Code in Ajax is:



//..
var options = {
url: "${pageContext.request.contextPath}/abc.html",
dataType : 'json',
contentType:'application/json',
data: JSON.stringify(taxList ),
beforeSubmit: function(data,set,options) {
if(!confirm("xxx?")) {
return false;
}
},

..//


Controller code:



@RequestMapping(value = "/abc.html", method = RequestMethod.POST)
public ModelAndView executeConfirmTaxHttpServletRequest request,
, @RequestBody List<KeyItemDto> taxList) {

System.out.println("taxList "+taxList);

}


With the above code im getting a NPE in Ajax at this line :



data: JSON.stringify(taxList ),


Not sure what is wrong with the code and how would it get passed to controller and retrieved. Any inputs appreciated.


Aucun commentaire:

Enregistrer un commentaire