Jpivot中MDX編輯器中文亂碼問題解決方案

來源:互聯網
上載者:User

使用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中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.