When using Springmvc and commons-fileupload-1.2.2.jar to upload files, the Chinese file names are garbled

When we use it to write uploaded files, we will have a problem, that is, there will be garbled characters when the Chinese file name is used. Here we need to set an encoding code, but after we operate, we will find that we put the web page, Changing both to utf-8 still does not solve the problem. In fact, the problem occurs when configuring the MultipartResolver processor, we need to add the red mark text:

<!-- When SpringMVC uploads files, you need to configure the MultipartResolver processor-->  
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
 <!-- Specifies that the total size of uploaded files cannot exceed 2000KB. Note that the limit of the maxUploadSize property is not for a single file, but the sum of the capacities of all files --> 
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="10485760000" />
<property name="defaultEncoding" value="utf-8"></property> 
<property name="maxInMemorySize" value="40960"></property> 
</bean>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325530540&siteId=291194637