form用pjax提交,request的Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryKa7A4askWRsS9x26,然后数据在Payload中,服务器接不到数据。
前端代码如下:
#@layout() #define main() <form testform class="ui form" action="/employee/save" method="post"> <table align="center"> <input type="hidden" name="id" value="#(emp.id)"> <tr> <td>工号:</td> <td><input type="text" name="code" value="#(emp.code)"></td> </tr> <tr> <td>姓名:</td> <td><input type="text" name="name" value="#(emp.name)"></td> </tr> <tr> <td>性别:</td> <td><input type="text" name="sex" value="#(emp.sex)"></td> </tr> <tr> <td>企业id:</td> <td><input type="text" name="companyId" value="#(emp.company_id)"></td> </tr> <tr> <td><button class="ui primary button" type="submit" ><i class="save icon"></i> 保存</button></td> </tr> </table> </form> <script type="text/javascript"> $(function(){ var tabid = dlayout.tab.conf.currentTabId; $(document).on('submit', 'form[testform]', function(event) { //sevent.preventDefault(); // stop default submit behavior $.pjax.submit(event, '#pjax-' + tabid, {push: false}); }); }); </script> #end
request header:
General Request URL:http://localhost/employee/save Request Method:POST Status Code:200 OK Remote Address:[::1]:80 Response Headers Content-Type:text/html;charset=UTF-8 Server:Jetty(8.1.8.v20121106) Transfer-Encoding:chunked Request Headers Accept:text/html, */*; q=0.01 Accept-Encoding:gzip, deflate Accept-Language:zh-CN,zh;q=0.8 Connection:keep-alive Content-Length:516 Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryaRTObSOQ5FGbMfBm Cookie:autoLogin=false; jfinalId=30e8c2fa79a048efb0e6b0393d35f668; _jfinal_captcha=80a2861819c84eef9a9c73fb93ae6631 Host:localhost Origin:http://localhost Referer:http://localhost/ User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.5194.400 QQBrowser/9.7.13269.400 X-PJAX:true X-PJAX-Container:#pjax-tab0 X-Requested-With:XMLHttpRequest Request Payload ------WebKitFormBoundaryaRTObSOQ5FGbMfBm Content-Disposition: form-data; name="id" 27 ------WebKitFormBoundaryaRTObSOQ5FGbMfBm Content-Disposition: form-data; name="code" 100 ------WebKitFormBoundaryaRTObSOQ5FGbMfBm Content-Disposition: form-data; name="name" bright1 ------WebKitFormBoundaryaRTObSOQ5FGbMfBm Content-Disposition: form-data; name="sex" 1 ------WebKitFormBoundaryaRTObSOQ5FGbMfBm Content-Disposition: form-data; name="companyId" 10 ------WebKitFormBoundaryaRTObSOQ5FGbMfBm--
跳转和pjax刷新都正常。