2012-03-24 61 views
0

我有一個網站應該以兩種語言顯示:Eng和Ru。 它是Tomcat6,Java6,Spring3,Tiles2。 網站確實以兩種語言顯示文字。但是,如果出現錯誤(並且我設置了自定義錯誤頁面),則俄語文本中的錯誤頁面顯示爲????????? (一堆?)西里爾文本不會顯示在錯誤頁面上

該文本在屬性文件中。認爲普通文本在一個文件中,錯誤消息在另一個文件中。我選中 - 兩個文件都使用相同的編碼進行保存。

在我的web.xml

我有這樣的:

<filter> 
     <filter-name>encodingFilter</filter-name> 
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
     <init-param> 
      <param-name>encoding</param-name> 
      <param-value>UTF-8</param-value> 
     </init-param> 
     <init-param> 
      <param-name>forceEncoding</param-name> 
      <param-value>true</param-value> 
     </init-param> 
    </filter> 
    <filter-mapping> 
     <filter-name>encodingFilter</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

和錯誤頁面是在web.xml中定義爲:

<error-page> 
    <error-code>400</error-code> 
    <location>/Exception</location> 
</error-page> 

<error-page> 
    <error-code>403</error-code> 
    <location>/Exception</location> 
</error-page> 

<error-page> 
    <error-code>404</error-code> 
    <location>/404</location> 
</error-page> 

<error-page> 
    <error-code>500</error-code> 
    <location>/Exception</location> 
</error-page> 

<error-page> 
    <error-code>503</error-code> 
    <location>/Exception</location> 
</error-page> 

<error-page> 
    <exception-type>java.lang.Exception</exception-type> 
    <location>/Exception</location> 
</error-page> 
在對myApp-servlet.xml中

我確實有這個

<bean id="messageSource" 
     class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
     <!-- <property name="basename" value="classpath:text" /> --> 

     <property name="basenames"> 
      <list> 
       <value>classpath:text</value> 
       <value>classpath:errors</value> 
      </list> 
     </property> 
     <property name="defaultEncoding" value="UTF-8" /> 
     <property name="fileEncodings" value="UTF-8" /> 
    </bean> 

再次,整個網站確實顯示俄文文本。這是錯誤頁面沒有。

是否有需要爲錯誤頁面指定的獨立設置?或者我錯過了什麼?

+0

當你得到的錯誤頁面,你可以右鍵點擊你的瀏覽器,並確認編碼是UTF-8? – 2012-03-24 22:05:52

回答

1

過濾器映射中有一個名爲調度器的參數。您應該添加以下到您的過濾器映射:

<dispatcher>REQUEST</dispatcher> 
<dispatcher>ERROR</dispatcher> 
+0

是的!就是這樣!它確實有效。 – Pinny 2012-03-26 14:46:23