`
zhuyx808
  • 浏览: 120869 次
  • 性别: Icon_minigender_1
  • 来自: 快来看~天上米有灰机
社区版块
存档分类
最新评论

对jwebap编码问题的解决

    博客分类:
  • web
阅读更多
把jwebap部署到系统上,本来觉得应该没什么事,可没想到编码出问题了,系统原来的默认编码是gbk,而jwebap用的是ISO8895_1,研究了一下,把过滤器改变下就能搞定DetectFilter.java

添加String charset="";

初始化的时候
public void init(FilterConfig filterConfig) throws ServletException {
		_filterConfig = filterConfig;
		this.charset=filterConfig.getInitParameter("charset");
	}

在方法doExclude中添加httprequest.setCharacterEncoding(charset);
在方法doFilter中添加req.setCharacterEncoding(charset);

web.xml中添加
<init-param>
<param-name>charset</param-name>
<param-value>GBK</param-value>
</init-param>

问题解决




jwebap作者leadyu回复如下:


如果你指的乱码问题是指URL的传参乱码,那可能是如下原因造成:

jwebap本身的处理是不涉及编码的,出现这个问题,我猜想最有可能出现的原因是jwebap的Http监控配置的PageDetectFilter造成的。可能的原因如下,你可以分析下:

PageDetectFilter里面会去读取request的URI,而你的应用里面我猜想可能存在某个用于处理URI编码的filter,你的filter通过调用request.setCharacterEncoding("gbk")来获取URI中的中文。而对于setCharacterEncoding,我们可以看JDK的注释是这样说明的:

Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader().

也就是说,这个方法必须在request第一次取参数和Reader之前被调用,也就是说,如果PageDetectFilter在你的filter之前执行,那么你的filter通过调用request.setCharacterEncoding("gbk")变成了无效,导致URI的中文无法正确取出。


解决办法,可以把PageDetectFilter的filter mapping配置在所有filter之后。

分享到:
评论

相关推荐

    jwebap_0.6.1

     1)基于ASM实现类的静态增强,可以无缝的部署于J2EE系统,对系统的开销几乎可以忽略  2) 部署和使用非常的简单,整个Jwebap的部署只需要部署jwebap_core_**.jar以及需要使用的各种plugin_**.jar,然后配置 ...

    jwebap应用

    NULL 博文链接:https://canofy.iteye.com/blog/286490

    jwebap 0.6

    NULL 博文链接:https://sunshinelife.iteye.com/blog/443560

    Jwebap使用手册(强烈推荐)

    Jwebap使用手册(强烈推荐),包括配置等。

    jwebap_0.5.9_1.jar

    Jwebap的开发分为两个部分Jwebap-core部分,Jwebap-plugin部分。core部分基于jdk14提供了类静态增强,轨迹生命管理,Plugin管理,视图框架等等,在这个基础上开发plugin。我觉得,好的profiling应该能够根据不同的...

    profiler工具Jwebap_0.5.2_alpha版发布

    博文链接:https://leadyu.iteye.com/blog/138576

    Jwebap User Guide 配置网站日志追踪

    NULL 博文链接:https://baobeituping.iteye.com/blog/629793

    jwebap_0.6.0_all.zip

    国内一个开源的profiler分析工具,特点是可以嵌入到web应用中,而不耦合业务代码。

    commontemplate-0.8.1.jar

    commontemplate-0.8.1.jar,是使用jwebap所需要的jar包。没有它,启动会有错误

Global site tag (gtag.js) - Google Analytics