简体   繁体   中英

unable to upload file with special character in Spring java

while uploading a file with special character name of file e- F CINE HD 1Break Sin Créd.mxf and it gets file name changed E- F CINE HD 1Break Sin Cre?D.Mxf of the special character in UI but name remain same in my database which have been uploaded.

and I got this error:

Invalid UTF-8 middle byte 0x64  at [Source: io.undertow.servlet.spec.ServletInputStreamImpl@4e6aff3c; line: 1, column: 735]

Try this config: Add this config in your web.xml file. Make sure you are adding the correct encoding value.

<filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>ISO-Latin-1</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM