前端

1.表单提交方法与格式

<form class="form-horizontal" action="/biz/patent/edit" method="post" enctype="multipart/form-data">

2.input注意不要写value=""

<input type="file" name="attorneyFile" />

 

后端

3.package org.springframework.web.multipart;

Entity.java

private MultipartFile attorneyFile;

4.entity.getAttorneyFile() != null不发生,即使你在HTML里没选任何文件, 仍然有实例,类型为DiskFileItem(package org.apache.commons.fileupload.disk)。

entity.getAttorneyFile() != null && !entity.getAttorneyFile() .getOriginalFilename().equals("")

注意:不能用getSize() > 0, 这样用户上传的空文件,就没法保存了。

相关文章:

  • 2021-09-11
  • 2021-11-22
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2022-02-07
  • 2022-12-23
  • 2022-01-13
  • 2022-02-09
  • 2022-12-23
  • 2021-05-25
  • 2022-02-22
相关资源
相似解决方案