(1) JSP displays the Chinese file name picture
method One, change the Server.xml file in Tomcat to:
Copy Code code as follows:
<connector port= "8080" maxhttpheadersize= "8192"
maxthreads= "minsparethreads=" maxsparethreads= "75"
Enablelookups= "false" redirectport= "8443" acceptcount= "100"
connectiontimeout= "20000" disableuploadtimeout= "true" uriencoding= "GBK"/>
JSP page:
Copy Code code as follows:
<%@ page import= "Java.net.URLEncoder"%>
method Two, in Tomcat's Server.xml
Add an attribute: uriencoding= "UTF-8"
after modification for:
Copy Code code as follows:
<connector port= "8080" protocol= "http/1.1"
maxthreads= "connectiontimeout=" "20000"
Redirectport= "8443" uriencoding= "UTF-8"/>
(2) display the picture under the absolute path
train of Thought: Read the file stream from the files on the local hard drive and use the servlet to read the pictures on the JSP page
Servlet Code:
Copy Code code as follows:
public void doget (HttpServletRequest request, httpservletresponse response)
Throws Servletexception, IOException {
Response.setcontenttype ("text/html; Charset=utf-8 ");
Response.setcontenttype ("Image/jpeg"); Format picture formatting, which can be ignored
FileInputStream fis = new FileInputStream ("d:/ftp/xxx.jpg");
OutputStream OS = Response.getoutputstream ();
try {
int count = 0;
byte[] buffer = new byte[1024*1024];
while ((count = fis.read (buffer))!=-1)
Os.write (buffer, 0, count);
catch (IOException e) {
E.printstacktrace ();
}finally {
if (os!=null)
Os.close ();
if (FIS!= null)
Fis.close ();
}
}
Refer directly to
Access the JSP page to display the picture.
I think the method is the simplest one, hehe! I have tried the method one, can solve my Chinese filename does not show the problem, in some thank Xiaoxiaoxuewen.