zoukankan      html  css  js  c++  java
  • Atitit.404错误解决标准流程and url汉字中文路径404错误resin4 resin chinese char path 404 err解决

    Atitit.404错误解决标准流程and url汉字中文路径404错误resin4 resin chinese char path 404 err解决

    1. #原因解析 1

    2. #解决方式 2

    3. 输出图片流... 2

    4. --code 2

    5. 参考 3

    1. #原因解析


    查看累挂发送d url,,,俄使用的是ff..它把url转换成个 http://localhost/img/QQ%E6%88%AA%E5%9B%BE20140401175433.jpg 发送出去..每汉字3%字符,所以,表明是utf8编码的url..


    服务端使用d resin4,估计不使用utf decodes..

     

    作者:: 老哇的爪子 Attilax 艾龙,  EMAIL:1466519819@qq.com

    转载请注明来源: http://blog.csdn.net/attilax

     

     

    只要在"resin.conf"里面把"static-encoding"设为"false"就一切OK(这样resin服务器好像不为JSP转换什么编码,显示任务仍了给浏览器。)。
    "request.setCharacterEncoding("GBK")"和<%@ page language="java" pageEncoding="GBK"%gt;都不用设置,数据库连接也不必加"useUnicode=true,characterEncoding=GBK"这种参数。(如果已经设置了,就应该全部删掉,在Tomcat上跑的时候是需要这些。)
    这种方法可能产生的一个问题是:在JavaGUI或者在控制台输出文字的时候因为编码没有转换过而显示乱码。这时候可以对文字做转码,如"new String(myString.getBytes("ISO-8859-1"))"。
    不过一个BS系统如果不包括JavaGUI,那就可以省很多中文处理的工作量。
    此方法,对字符串的对比和模糊查询都有效。


    2. #解决方式


    1.更改resin4 cfg ,设置utf8url参数解析....se,设置lei 不起效果...只好自己解决le ..
    2.urlrewrtite>>servlet ,自己解析url参数,输出图片流...

    一个filter

     

    思路::filere>>urldecode>>img io》》output  servlet

     

    3. 输出图片流...

    String f=pathx.webAppPath()+File.separator+url2;

    BufferedImage bi = ImageIO.read(new File(f));

    ImageIO.write(bi"jpg"response.getOutputStream());

    如果使用传统jdkstream太麻烦蓝。。。

    4. --code

     

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

    public void doFilter(ServletRequest request, ServletResponse response,

    FilterChain chainthrows 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");

    //用init方法取得的charset覆盖被拦截下来的request对象的charset  

            request.setCharacterEncoding(this.charset);  

            //将请求移交给下一下过滤器,如果还有的情况下。  

            chain.doFilter(requestresponse);  

    }

     

    5. 参考

    paip.解决中文url路径的问题图片文件不能显示 - attilax的专栏 博客频道 - CSDN.NET.html

    Resin的中文问题最简单的解决方法 - Thinking In Jdon.html

  • 相关阅读:
    转:SkipList跳表
    git操作
    JAVA小工具打包
    Java数字证书操作
    mysql创建数据库和用户
    解决node-sass安装不了的问题
    vscode + angular
    ng2 quickstart-primeng
    ng2 quickstart
    使用淘宝的npm代理下载模块
  • 原文地址:https://www.cnblogs.com/attilax/p/5963709.html
Copyright © 2011-2022 走看看