Paip. Troubleshoot problems with Chinese URL paths picture files cannot be displayed
Source: Internet
Author: User
Paip. Troubleshoot problems with Chinese URL paths picture files cannot be displayed
#现状: Chinese URL path picture file cannot be displayed
#原因解析
View tired-hung send D URL,,, Russia is using FF. It converts the URL into a http://localhost/img/QQ%E6%88%AA%E5%9B%BE20140401175433.jpg and sends it out. 3% characters per kanji, so, indicates that the URL is UTF8 encoded:
The server side uses D RESIN4, which is estimated not to use UTF decodes.
#解决方式
1. Change resin4 cfg, set UTF8 to URL parameter resolution .... SE, set the LEI to be ineffective ... Had to solve their own le.
2.urlrewrtite>>servlet, self-parsing URL parameters, output picture stream ...
First use JSP output picture stream, online said is ok Lan SE, walk ten not, teeth don't know why ... As basic as the output of a servlet salam ...
Author Old Wow's paw Attilax Ayron, email:1466519819@qq.com
Source: Http://blog.csdn.net/attilax
##/imserver/webroot/web-inf/urlrewrite.xml
<rule>
<FROM>/.*QQ (. *) .jpg</from>
<to>/visitorBuscard_list.json?data=showimg&urlCnChar=$1</to>
</rule>
# # Spring MVC cfg
Todo Spring MVC hot Deplyoy
@RequestMapping (value = "/visitorbuscard_list")
public void Visitorbuscard_list (String data, HttpServletResponse response,httpservletrequest request) {
Core.log ("--data:" +data);
if (data!=null) {
if (Data.equals ("Probelist"))
{
Baselist (Response,new Tprobecustomdao ());
}else if (data.equals ("Vistinvtset"))
{
New Probeservice (). Savevistinvtset (Request);
}
else if (data.equals ("showimg"))
{
IMGSERVICE.OUTPUTIMG (request, response);
}
}else
# #pasrse URL parameters, output pic
public static void Outputimg (HttpServletRequest req,
HttpServletResponse response) {
, but when the picture is displayed in the JSP view, an exception is thrown Getoutputstream () has already been called for this response, because the request's output stream has been opened by the servlet by default , we all know that the JSP will eventually be converted into a servlet, and the output stream of the servlet is open, cannot be closed (I tested), so using JSP to open the output stream is not feasible.
So, helpless, we can only use the original servlet to achieve this function, you can directly through the servlet output stream to display the picture, no need to open the output stream
#my
Content-type Image/jpeg; CHARSET=GBK Jeig BSI Juyaowenti.
Date Thu, APR 03:04:12 GMT
Server resin/4.0.22
Transfer-encoding chunked
Content-length 8802
Content-type Image/jpeg; Charset=gbk
Date Thu, APR 03:07:16 GMT
Server resin/4.0.22
Err
Cache-control No-cache
Content-type Image/jpeg; Charset=gbk
Date Thu, APR 03:57:47 GMT
Expires Thu, Jan 1970 00:00:00 GMT
Server resin/4.0.22
Transfer-encoding chunked, chunked
---corect
Cache-control No-cache
Content-type Image/jpeg; Charset=gbk
Date Thu, APR 03:58:49 GMT
Expires Thu, Jan 1970 00:00:00 GMT
Server resin/4.0.22
Transfer-encoding chunked, chunked
Reference:
RESIN4 Chinese Problem Solving-newflypig's column-Blog channel-csdn.net
How tomcat and resin server is set to UTF8 encoding-thought is more important than knowledge growth is more important than success-Blogjava
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.