Note that there are some explanatory texts on larger screens.

plurals
  1. POusing spring mvc to upload, but MultipartFile is null
    text
    copied!<pre><code> @ResponseBody @RequestMapping(value = "companyTypeRelation/toupload") public String uploadCompanyTypeRelation( @RequestParam(value = "uploadfile", required = false) MultipartFile[] uploadfile, HttpServletRequest request,HttpServletResponse response) { // do logic } </code></pre> <p><strong>i use ajax to send;but i find MultipartFile is null, i can get the value ;i don't know how do solve it?</strong> below is jsp detail:</p> <pre><code>&lt;div class="upload" id="uploadDIV" title="upload" style="text-align: center; display: none; padding: 5px;"&gt; &lt;center&gt; &lt;a href="${pageContext.request.contextPath }/report/Excels/blalist.xls"&gt;uploadupload&lt;/a&gt; &lt;form action="${pageContext.request.contextPath }/backend/basic/companyTypeRelation/toupload" id="UploadForm" method="post" enctype="multipart/form-data"&gt; &lt;br /&gt; &lt;input type="file" id="uploadfile" name="uploadfile"&gt;&lt;/input&gt; &lt;/form&gt; &lt;/center&gt; &lt;/div&gt; </code></pre> <p>i use ajax send file form to server ,maybe there is problem ,but i don't figue it out :</p> <pre><code>enter code here $("#uploadDIV").dialog({ autoOpen : false, height : 200, width : 450, modal : true, buttons : { "commit" : function() { var filepath = document .getElementById("uploadfile").value; var re_text = /\xls/i; var newFileName = filepath.split('.'); newFileName = newFileName[newFileName.length - 1]; if (newFileName.search(re_text) == -1) { return; } var resourceURL = '${pageContext.request.contextPath}/backend/basic/companyTypeRelation/toupload'; //$("#UploadForm").submit(); $.ajax({ url:resourceURL, type: 'POST', data: { }, error: function(XMLHttpRequest, textStatus, errorThrown){ $(".validateTips").text("..."); }, success: function(data){ alert(data); } }); }, "cancel" : function() { $(this).dialog("close"); } }, close : function() { allFields.val("").removeClass( "ui-state-error"); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload