Jpivot中MDX编辑器中文乱码问题解决方案
2010-10-19 10:00
465 查看
使用Jpivot中的MDX编辑器时,当MDX语句中出现中文时,点击应用后把MDX语句中的所有中文变成乱码,出现这样的问题在WCF文档中有解决方案;
可以参考wcf中的api:
Package com.tonbeller.wcf.charset Description
Forces the request encoding to UTF-8 or another configurable character encoding.
Problem: in servlet 2.3, when ServletResponse#setLocale(java.util.Locale) is called, the character encoding is changed implicit in an unspecified way. To prevent this, this wrapper does not forward the setLocale call. All JSTL fmt:xxx actions call setLocale on the response, which causes the problem.
This package uses a response wrapper that does not allow the character encoding to be changed. Also the filter sets the Request encoding to UTF-8 (or another configurable charset) because most browsers dont follow the http spec and do not send a content-type header when submitting a form. They use the character encoding of the page that contained the form.
The encoding is configurable as filter init parameter encoding, via the property tbeller.charset. If the filter is installed, it defaults to UTF-8, otherwise it defaults to ISO-8859-1.
The filter automatically changes (or adds) the response encoding of one configurable content-type. If the filter init-param contentType is set to text/html, then a response content type will of "text/html; charset=iso-8859-1" will be changed into "text/html; charset=utf-8".
The ContentTypeTag sets the content-type and character encoding of the response to the given type.
但是它使用的例子出现了问题,这里更正为:
Filter example:
<filter>
<filter-name>CharsetFilter</filter-name>
<filter-class>com.tonbeller.wcf.charset.CharsetFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value><!--api中这里写错了,要支持中文大部分都是用UTF-8,-->
<description>character encoding that this filter will enforce</description>
</init-param>
<init-param>
<param-name>contentType</param-name>
<param-value>text/html</param-value>
<description>this content type will be set to the above encoding automatically, e.g. "text/html; charset=iso-8859-1" will become "text/html; charset=utf-8"</description>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharsetFilter</filter-name>
<url-pattern>*.jsp</url-pattern><!--我过滤的所有jsp文件,你可以过滤具体的页面或文件夹-->
</filter-mapping>
问题的解决方案就是把上述过滤器添加到web.xml中
可以参考wcf中的api:
Package com.tonbeller.wcf.charset Description
Forces the request encoding to UTF-8 or another configurable character encoding.
Problem: in servlet 2.3, when ServletResponse#setLocale(java.util.Locale) is called, the character encoding is changed implicit in an unspecified way. To prevent this, this wrapper does not forward the setLocale call. All JSTL fmt:xxx actions call setLocale on the response, which causes the problem.
This package uses a response wrapper that does not allow the character encoding to be changed. Also the filter sets the Request encoding to UTF-8 (or another configurable charset) because most browsers dont follow the http spec and do not send a content-type header when submitting a form. They use the character encoding of the page that contained the form.
The encoding is configurable as filter init parameter encoding, via the property tbeller.charset. If the filter is installed, it defaults to UTF-8, otherwise it defaults to ISO-8859-1.
The filter automatically changes (or adds) the response encoding of one configurable content-type. If the filter init-param contentType is set to text/html, then a response content type will of "text/html; charset=iso-8859-1" will be changed into "text/html; charset=utf-8".
The ContentTypeTag sets the content-type and character encoding of the response to the given type.
但是它使用的例子出现了问题,这里更正为:
Filter example:
<filter>
<filter-name>CharsetFilter</filter-name>
<filter-class>com.tonbeller.wcf.charset.CharsetFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value><!--api中这里写错了,要支持中文大部分都是用UTF-8,-->
<description>character encoding that this filter will enforce</description>
</init-param>
<init-param>
<param-name>contentType</param-name>
<param-value>text/html</param-value>
<description>this content type will be set to the above encoding automatically, e.g. "text/html; charset=iso-8859-1" will become "text/html; charset=utf-8"</description>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharsetFilter</filter-name>
<url-pattern>*.jsp</url-pattern><!--我过滤的所有jsp文件,你可以过滤具体的页面或文件夹-->
</filter-mapping>
问题的解决方案就是把上述过滤器添加到web.xml中
相关文章推荐
- Jpivot mdx查询编辑器输入中文乱码问题
- Jpivot mdx查询编辑器和Jpivot导出PDF、Excel中文乱码问题
- ndk开发过程中中文乱码问题的解决方案
- 安卓httprul post方式上传中文乱码问题解决方案
- Ajax中文乱码问题解决方案
- Servlet 中文乱码问题及解决方案剖析
- Mac 下 MySQL 5.7 连接 navicat 中文乱码问题终极解决方案
- [转]Servlet 中文乱码问题及解决方案剖析
- eclipse环境import工程出现中文乱码问题的解决方案
- sublime 3中文乱码问题解决方案
- 使用JSP开发应用程序时的编码(中文等乱码)问题的建议解决方案(包括接受request和数据库操作)
- ubuntu 下mysql中文乱码问题解决方案
- JSP开发过程遇到的中文乱码问题及解决方案
- eclipse中文乱码问题解决方案
- GeoServer之shapefile中文乱码问题解决方案
- Servlet 中文乱码问题及解决方案剖析
- JSP中文乱码问题终极解决方案
- 腾讯微博API 返回数据中文乱码的问题的解决方案
- Mysql中文乱码问题完美解决方案
- Servlet 中文乱码问题及解决方案剖析