Atitit.url 汉字中文路径  404 resin4 resin  解决  v2 q329

本文介绍了一种在 Resin 服务器环境下解决中文路径导致 404 错误的方法,通过使用 Pluginx 机制及自定义过滤器实现了对含有中文字符的 URL 请求的有效处理。

Atitit.url 汉字中文路径  404 resin4 resin  解决  v2 q329

 

 

1. Pluginx机制1

2. Code1

3. 参考4

 

1. 原理

过滤器  ,,拦截jpg  with %url...read img ,直接输出..

2. Pluginx机制

//if()

if(inied==false ||  new File("c:\\chinese_filename_hook_ini_pertime").exists()) {

new Pluginx().remove_all_filters("chinese_filename_hook");

new Pluginx().add_action("chinese_filename_hook", new JpgFilerProcesser());

new Pluginx().add_action("chinese_filename_hook", new TxtFilerProcesser());

inied=true;

}

}

 

作者::  ★(attilax)>>>   绰号:老哇的爪子  全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊  汉字名:艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://blog.youkuaiyun.com/attilax

 

 

3. Code

 

package com.attilax.corePkg;

 

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.io.UnsupportedEncodingException;

import java.net.URLDecoder;

import java.util.HashMap;

import java.util.Map;

 

import javax.imageio.IIOException;

import javax.imageio.ImageIO;

import javax.servlet.Filter;

import javax.servlet.FilterChain;

import javax.servlet.FilterConfig;

import javax.servlet.ServletException;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;

import javax.servlet.annotation.WebFilter;

import javax.servlet.http.HttpServletRequest;

 

 

 

 

 

 

 

 

 

 

 

 

import aaaCfg.IocX;

 

 

 

 

import com.attilax.core;

import com.attilax.jsonX;

import com.attilax.io.filex;

import com.attilax.io.pathx;

import com.attilax.lang.Global;

import com.attilax.lang.Pluginx;

import com.attilax.net.JpgFilerProcesser;

import com.google.common.collect.Maps;

import com.sun.image.codec.jpeg.JPEGCodec;

 

/**

 * com.focusx.util

 * EncodingFilter.java

 * author:vincente  2013-8-19

 */

@WebFilter(filterName = "ChineseCharFileUrlFilterName", urlPatterns = "/*") 

public class ChineseCharFileUrlFilter implements Filter {

 

private String charset;  

public void destroy() {

// TODO Auto-generated method stub

 

}

 

@SuppressWarnings("all")

public void doFilter(ServletRequest request, ServletResponse response,

FilterChain chain) throws IOException, ServletException {

 

try {

if(Global.map.get()==null)

Global.map.set(new HashMap());

Global.map.get().put("FileSeverDir", "Z:\\动作类");

new Pluginx().remove_all_filters("chinese_filename_hook");

new Pluginx().add_action("chinese_filename_hook", new JpgFilerProcesser(),0,null,null);

//new Pluginx().add_action("chinese_filename_hook", new TxtFilerProcesser());

Map m=new HashMap ();

m.put("req", request);

m.put("res", response);

new Pluginx().do_action("chinese_filename_hook",m,null);

} catch (Exception e) {

e.printStackTrace();

}

 

core.log("--loadorderO9::EncodingFilter");

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

        request.setCharacterEncoding(this.charset);  

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

        chain.doFilter(request, response);  

}

 

//private String getImgPath(String url2) {

//String str;

//try {

//str = new String(url2.toString().getBytes("iso8859_1"), "GB2312");

//} catch (UnsupportedEncodingException e) {

//e.printStackTrace();

//throw new RuntimeException(e);

//}

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

//File file = new File(f);

//return f;

//}

public void init(FilterConfig config) throws ServletException {

//从web.xml中的filter的配制信息中取得字符集  

        this.charset = config.getInitParameter("charset");  

}

 

}

4. 参考

 

url汉字中文路径404异常resin4 resin chinese char path 404 err解决

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值