<legend id='mXGYF'><style id='mXGYF'><dir id='mXGYF'><q id='mXGYF'></q></dir></style></legend>

      <small id='mXGYF'></small><noframes id='mXGYF'>

      • <bdo id='mXGYF'></bdo><ul id='mXGYF'></ul>
        <i id='mXGYF'><tr id='mXGYF'><dt id='mXGYF'><q id='mXGYF'><span id='mXGYF'><b id='mXGYF'><form id='mXGYF'><ins id='mXGYF'></ins><ul id='mXGYF'></ul><sub id='mXGYF'></sub></form><legend id='mXGYF'></legend><bdo id='mXGYF'><pre id='mXGYF'><center id='mXGYF'></center></pre></bdo></b><th id='mXGYF'></th></span></q></dt></tr></i><div id='mXGYF'><tfoot id='mXGYF'></tfoot><dl id='mXGYF'><fieldset id='mXGYF'></fieldset></dl></div>

      1. <tfoot id='mXGYF'></tfoot>

      2. 如何使用 blueimp jQuery 文件上传:Struts 2 中的空文件上传结果,文件项为空

        How to use blueimp jQuery file upload: Empty file upload result in Struts 2, fileitems are empty(如何使用 blueimp jQuery 文件上传:Struts 2 中的空文件上传结果,文件项为空)

        1. <legend id='zXkyh'><style id='zXkyh'><dir id='zXkyh'><q id='zXkyh'></q></dir></style></legend>
            <tbody id='zXkyh'></tbody>

            <bdo id='zXkyh'></bdo><ul id='zXkyh'></ul>

              <small id='zXkyh'></small><noframes id='zXkyh'>

              <tfoot id='zXkyh'></tfoot>

                • <i id='zXkyh'><tr id='zXkyh'><dt id='zXkyh'><q id='zXkyh'><span id='zXkyh'><b id='zXkyh'><form id='zXkyh'><ins id='zXkyh'></ins><ul id='zXkyh'></ul><sub id='zXkyh'></sub></form><legend id='zXkyh'></legend><bdo id='zXkyh'><pre id='zXkyh'><center id='zXkyh'></center></pre></bdo></b><th id='zXkyh'></th></span></q></dt></tr></i><div id='zXkyh'><tfoot id='zXkyh'></tfoot><dl id='zXkyh'><fieldset id='zXkyh'></fieldset></dl></div>
                • 本文介绍了如何使用 blueimp jQuery 文件上传:Struts 2 中的空文件上传结果,文件项为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用的是 Blueimp,服务器端是 Java,Struts2.我找不到使用 Java 的示例,无论如何我设法使用了示例代码,但是当我也尝试上传单个文件时,我得到了 空文件上传结果".HTML部分是一样的,这里就不贴了,可能会很长.

                  I am using Blueimp and server side is Java, Struts2. I couldn't find examples using Java, anyway I managed to use the sample code, but I am getting "Empty file upload result" when I am trying to upload a single file also. The HTML part is the same, I am not pasting here as it may go lengthy.

                  jQuery 是:

                  $(document).ready(function () {
                      'use strict';
                  
                      // Initialize the jQuery File Upload widget:
                      $('#fileupload').fileupload();
                  
                      // Enable iframe cross-domain access via redirect option:
                      $('#fileupload').fileupload(
                          'option',
                          'redirect',
                          window.location.href.replace(
                              //[^/]*$/,
                              '/cors/result.html?%s'
                          )
                      );
                  
                      if (window.location.hostname === 'blueimp.github.com') {
                          // Demo settings:
                          $('#fileupload').fileupload('option', {
                              url: '//jquery-file-upload.appspot.com/',
                              maxFileSize: 5000000,
                              acceptFileTypes: /(.|/)(gif|jpe?g|png)$/i,
                              process: [
                                  {
                                      action: 'load',
                                      fileTypes: /^image/(gif|jpeg|png)$/,
                                      maxFileSize: 20000000 // 20MB
                                  },
                                  {
                                      action: 'resize',
                                      maxWidth: 1440,
                                      maxHeight: 900
                                  },
                                  {
                                      action: 'save'
                                  }
                              ]
                          });
                          // Upload server status check for browsers with CORS support:
                          if ($.support.cors) {
                              $.ajax({
                                  url: '//jquery-file-upload.appspot.com/',
                                  type: 'HEAD'
                              }).fail(function () {
                                  $('<span class="alert alert-error"/>')
                                      .text('Upload server currently unavailable - ' +
                                              new Date())
                                      .appendTo('#fileupload');
                              });
                          }
                      } else {
                          // Load existing files:
                          $('#fileupload').each(function () {
                              var that = this;
                              $.getJSON(this.action, function (result) {
                                  if (result && result.length) {
                                      $(that).fileupload('option', 'done')
                                          .call(that, null, {result: result});
                                  }
                              });
                          });
                      }
                  
                  });
                  

                  动作:

                  @Namespace("/")
                  @InterceptorRefs({
                    @InterceptorRef("fileUpload"),
                    @InterceptorRef("basicStack")
                  })
                  public class UploadAction extends ActionSupport implements ServletRequestAware, ServletResponseAware{
                  
                      HttpServletRequest req;
                      HttpServletResponse res;
                    //  private File fileUploadPath=new File("c:\temp\");
                      private List<File> uploads = new ArrayList<File>();
                      private List<String> uploadFileNames = new ArrayList<String>();
                      private List<String> uploadContentTypes = new ArrayList<String>();
                  
                      public List<File> getUploads() {
                          return uploads;
                      }
                  
                      public void setUploads(List<File> uploads) {
                          this.uploads = uploads;
                      }
                  
                      public List<String> getUploadFileNames() {
                          return uploadFileNames;
                      }
                  
                      public void setUploadFileNames(List<String> uploadFileNames) {
                          this.uploadFileNames = uploadFileNames;
                      }
                  
                      public List<String> getUploadContentTypes() {
                          return uploadContentTypes;
                      }
                  
                      public void setUploadContentTypes(List<String> uploadContentTypes) {
                          this.uploadContentTypes = uploadContentTypes;
                      }
                      
                      @Action(value="upload", results = { @Result(name="success", type="json")
                      })
                      public String uploadFiles() throws IOException
                      {
                          System.out.println("upload1");
                          System.out.println("files:");
                          for (File u: uploads) {
                              System.out.println("*** "+u+"	"+u.length());
                          }
                          System.out.println("filenames:");
                          for (String n: uploadFileNames) {
                              System.out.println("*** "+n);
                          }
                          System.out.println("content types:");
                          for (String c: uploadContentTypes) {
                              System.out.println("*** "+c);
                          }
                          System.out.println("
                  
                  ");
                          if (!ServletFileUpload.isMultipartContent(req)) {
                              throw new IllegalArgumentException("Request is not multipart, please 'multipart/form-data' enctype for your form.");
                          }
                          return SUCCESS;
                      }
                      
                      @Override
                      public void setServletRequest(HttpServletRequest hsr) {
                          this.req=hsr;
                      }
                  
                      @Override
                      public void setServletResponse(HttpServletResponse hsr) {
                          this.res=hsr;
                      }
                      
                  }
                  

                  正如我所说,我已经更改了操作文件,但我仍然得到文件的所有空值,并且在 Firebug 的 GET 响应中我看到 "Request is not multipart, please 'multipart/form-data'enctype 为您的表单".

                  As I said, I have changed the action file, but I still get all empty values for files, and in the Firebug's GET response I see "Request is not multipart, please 'multipart/form-data' enctype for your form".

                  推荐答案

                  你可以使用 fileUpload 拦截器 来解析你的 "multipart/form-data" 请求.它使用由 commons-fileupload 实现.apache.org/maven/struts2-core/apidocs/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.html" rel="nofollow noreferrer">MultipartRequestWrapper 由 Struts2 调度程序准备操作.您可以在这里找到更多关于如何上传文件的示例.

                  You may use fileUpload interceptor to parse your "multipart/form-data" requests. It uses the same commons-fileupload implementation wrapped by the MultipartRequestWrapper in prepare operations by the Struts2 dispatcher. More about how to file upload with examples you could find here.

                  这篇关于如何使用 blueimp jQuery 文件上传:Struts 2 中的空文件上传结果,文件项为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)

                    <small id='iHl2O'></small><noframes id='iHl2O'>

                      <tbody id='iHl2O'></tbody>
                        <i id='iHl2O'><tr id='iHl2O'><dt id='iHl2O'><q id='iHl2O'><span id='iHl2O'><b id='iHl2O'><form id='iHl2O'><ins id='iHl2O'></ins><ul id='iHl2O'></ul><sub id='iHl2O'></sub></form><legend id='iHl2O'></legend><bdo id='iHl2O'><pre id='iHl2O'><center id='iHl2O'></center></pre></bdo></b><th id='iHl2O'></th></span></q></dt></tr></i><div id='iHl2O'><tfoot id='iHl2O'></tfoot><dl id='iHl2O'><fieldset id='iHl2O'></fieldset></dl></div>
                          <bdo id='iHl2O'></bdo><ul id='iHl2O'></ul>

                          1. <legend id='iHl2O'><style id='iHl2O'><dir id='iHl2O'><q id='iHl2O'></q></dir></style></legend>
                          2. <tfoot id='iHl2O'></tfoot>