ATITIT.404 error resolution standard process and URL Chinese path 404 error resin4 resin chinese char path 404 err Resolve

Source: Internet
Author: User

ATITIT.404 Error Resolution standard process and URL Chinese path 404 error resin4 resin Chinese char path 404 Err resolved

1. # cause resolution 1

2. # Solution 2

3. Output picture stream ... 2

4.--code 2

5. Reference 3

1. #Cause resolution


View tired-hung send d url,,, Russian using ff ... it put url HTTP://LOCALHOST/IMG/QQ%E6%88%AA%E5%9B%BE20140401175433.JPG  send out each Chinese character 3 % character so indicates that it is utf8 coded url:


The server side uses D RESIN4, which is estimated not to use UTF decodes .

Author:: Old Wow's paw attilax Ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

just set "Static-encoding" to "false" in "resin.conf" and all OK (so that the resin server does not seem to be converting what encoding for JSP, the display task is still given to the browser.) )。
"request.setcharacterencoding (" GBK ")" and <%@ page language= "java" pageencoding= "GBK"%GT; no settings, no database connection required " USEUNICODE=TRUE,CHARACTERENCODING=GBK "This parameter. (if it's already set up, it should all be erased, which is needed when running on Tomcat.) )
One possible problem with this approach is that it is garbled when the Javagui or the console outputs text because the encoding has not been converted. In this case, you can transcode the text, such as "New String (Mystring.getbytes (" Iso-8859-1 ")).
However, if a BS system does not include Javagui, it can save a lot of Chinese processing work.
This method is valid for both string comparisons and fuzzy queries.


2. #How to solve


1. change resin4 cfg, set UTF8 for URL parameter resolution ... . SE, Set the lei to be ineffective ... I had to solve it myself le..
2.urlrewrtite>>servlet, self-parsing URL parameters , output picture stream ...

a Filter

idea:: filere>>urldecode>>img io"output servlet

3. Output Picture Stream...

String F =pathx. Webapppath () +file. Separator + Url2 ;

BufferedImage Bi = ImageIO. Read (new File (F));

ImageIO. Write (bi, "jpg", response. Getoutputstream ());

If the stream using traditional jdk is too troublesome blue ...

4.--code

/vod2/src/com/focusx/util/encodingfilter.java

Public void doFilter (servletrequest request, Servletresponse response ,

Filterchain chain ) throws IOException, servletexception {

HttpServletRequest req = (httpservletrequest) Request ;

String Requesturl  =  req . Getrequesturl (). toString ();

Http://localhost:8080/vdx/static/%E8%9D%99%E8%9D%A0%E4%BE%A0-%E9%BB%91%E6%9A%97%E9%AA%91%E5%A3%AB.jpg

Try  {

//must in Try: Cause youed png D,ext sh jpgd , Output D siheur  . Erro ...

if (requesturl. EndsWith (". jpg"))

{

Requesturl = Requesturl . ReplaceAll ("http://", " ");

int idx=requesturl. IndexOf ("/");

String s = Requesturl . substring (idx+ 1);

int idx2=s. IndexOf ("/");

String Url2 = s . substring (idx2+ 1);

%e8%9d%99%e8%9d%a0%e4%be%a0-%e9%bb%91%e6%9a%97

Url2 =urldecoder. Decode (url2,"Utf-8");

String F =pathx. Webapppath () +file. Separator + Url2 ;

BufferedImage Bi = ImageIO. Read (new File (F));

ImageIO. Write (bi, "jpg", response. Getoutputstream ());

return ;

}

} catch (Exception e) {

//  TODO : Handle Exception

}

Core. Log ("--loadordero9::encodingfilter");

//With Init method obtained by CharSet overwrite the intercepted request object. CharSet   

Request. setcharacterencoding (this. CharSet  );

//Transfer the request to the next filter, if there is a situation.

chain. DoFilter (request, response);

}

5. Reference

Paip. solve Chinese URL problem with path picture file cannot be displayed -Attilax 's Column -  Blog Channel -CSDN.NET.html

The simplest solution to Resin's Chinese problem -thinking in jdon.html

ATITIT.404 error resolution standard process and URL Chinese path 404 error resin4 resin chinese char path 404 err Resolve

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.