Reprint: http://lofei117.iteye.com/blog/1074182
Images are often used in Web pages and are displayed on the page via IMG tags or filters. When the file name is a Chinese name, you will see that the picture does not load correctly, which prevents it from appearing.
The solution is as follows:
1: Change the configuration of the server, so that the server supports utf-8 to display pictures. This test is valid, but one thing is that the server configuration has been modified, and then use the request to get parameters, Chinese garbled problem. The parameters that are printed by System.out.print are correct, but are not the correct values after assigning to the string object, and are still incorrect after being converted by the GetBytes method of the string object. So I gave up this method.
Reference:
In the HTML page, a picture with Chinese characters is referenced, such as if uriencoding is not configured in Tomcat, it cannot be displayed. Modification Method:
Add uriencoding= "Utf-8" to Tomcat's Server.xml (page encoding is utf-8)
<connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000" disableuploadtimeout= "true" URIEncoding= " Utf-8 "redirectport=" 8443 "/>
2: The way I think about it, there may have been other people who have figured it out. is to give the Chinese name with Utf-8 code, out a string with the% number, corresponding to the corresponding file name. Of course this is not enough, because this file name browser will automatically escape decoding to the corresponding Chinese name, the picture still cannot be displayed. So I used the Replace method of the string object to replace all of the file name with the--and then the picture was displayed correctly. The disadvantage is that finding filenames is not easy to identify.
The coding problem is really chilling, especially where Chinese is concerned.
Mark, I hope to help you a little bit, also give yourself some notes, accumulate the knowledge that you have learned.
String name = "hahaha";
String str = java.net.URLEncoder.encode (name, "Utf-8");
After escaping for the%e5%93%88%e5%93%88%e5%93%88
str = str.replace ("%", "-");
-e5-93-88-e5-93-88-e5-93-88 after replacement
The file name is then added with the appropriate extension. You can either store the database or save the file name directly.
Solutions for images in a webpage that cannot be displayed in Chinese names