Nicht analysieren konnte-servlet, multipart-request; verschachtelte Ausnahme ist FileUploadException: der Antrag wurde abgelehnt, weil keine multipart-Grenze gefunden wurde

In meinem aktuellen spring-boot-Projekt, habe ich dieses Formular zum hochladen einer war-Datei auf dem server:

    <form:war>
        <div class="field-box">
             <label th:text="${war}"></label>
             <div class="col-md-7">
                 <input class="form-control arquivo" th:attr="data-classe=${command['class'].simpleName},target=${war}" th:id="${war}" type="file" />
             </div>
         </div>
    </form:war>

form behandelt wird, die von dieser controller-Methode:

  @RequestMapping(value="download", method=RequestMethod.GET)
    @ResponseBody
    public HttpEntity<byte[]> download(@RequestParam(value="id") String id) throws Exception {
        return this.serv.download(id);
    }

und durch diese Methode in der service Klasse:

  public String upload(String id, String classe, String target, MultipartFile file) throws Exception {
    Arquivo novo;
    if(id == null) {
      novo = new Arquivo(classe, target);
      this.dao.insert(novo);
            id = novo.getId();
    } else {
      novo = this.dao.findById(id);
    }

    byte[] bytes = file.getBytes();
    File arquivo = new File(novo.toString());
    if(!arquivo.exists())
            if(arquivo.mkdirs())
                arquivo.createNewFile();

    BufferedOutputStream stream = new BufferedOutputStream( new FileOutputStream(arquivo) );
    stream.write(bytes);
    stream.close();

    return novo.getId();
  }

all dies wird ausgelöst durch das jquery-code:

        $("input.arquivo").on("change", function(event){
            console.log('mudanca no campo de arquivo');
            var c = $(this).data('classe');
            var t = $(this).data('target');
            var f = $(this).val();
            $.ajax({
                method: "POST",
                url: "/Picture/upload",
                data: { classe: c, target: t, file: f },
                contentType: "multipart/form-data"
            }).done(function(data){
                console.log('id: '+data);
                $(this).attr('type', 'hidden');
                $(this).attr('name', t);
                $(this).attr('value', data)
            });
        });

meiner Anwendung.Eigenschaften dieser Konfiguration:

# Multipart Configuration
multipart.location = ${user.home}/.lojacms/Uploads
multipart.maxFileSize = 100Mb
multipart.maxRequestSize = 100Mb
multipart.fileSizeThreshold = 10Mb

aber wenn ich versuche eine Datei hochzuladen, bekomme ich die oben beschriebenen Fehler (in der überschrift). Wer kann mir sagen, was ist hier falsch?

  • Könntest du deinen controller RequestMapping für Ihren laden?
InformationsquelleAutor Kleber Mota | 2015-09-20
Schreibe einen Kommentar