1. 程式人生 > >springmvc無法接收ajax提交form表單的實體類資訊

springmvc無法接收ajax提交form表單的實體類資訊

前端接受資料:

function commitConfirm(){

var recept_sn=document.getElementById("recept_sn").value;
alert(recept_sn);
var customer_name=document.getElementById("customer_name").value;
alert(customer_name);
alert($('#predealForm').serialize());
$.ajax({
            url:"${pageContext.request.contextPath}/ida40/pacify/operate/pacifyTaskAccept.jhtml",
            type:"post",
            data:$('#predealForm').serialize(),
            processData:false,
            contentType:false,
            success:function(data){
                console.log("over..");
            }
});

}

前端頁面:

 <form id="predealForm">

<input id="recept_sn" name="recept_sn" value="" class="ida-input-text" style="width:220px">
<ida:idaButton value="查詢" onclick="showUserDetail();" />

</form>

後臺:

   @RequestMapping(value = "/pacifyTaskAccept.jhtml", method = RequestMethod.POST)
    public void entry(HttpServletResponse response, HttpServletRequest request,ModelMap model,@ModelAttribute PacifyTaskReceiveDTO pacifyTaskReceiveDTO) throws BOException,
           BIException, ServletException, IOException {
    System.out.println(pacifyTaskReceiveDTO);
    System.out.println(pacifyTaskReceiveDTO.getService_no());
    System.out.println(pacifyTaskReceiveDTO.getCustomer_name());
    System.out.println(pacifyTaskReceiveDTO.getDealObjectId());
   
    }

解決方法:

去掉ajax中的即可。

   processData:false,
            contentType:false,