我有一个应该以两种语言显示的网站: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>
而且,整个网站确实正确显示了俄语文本。是错误页面没有。
我需要为错误页面指定单独的设置吗?还是我遗漏了什么?
最佳答案
filter-mapping 中有一个参数叫做dispatcher。您应该将以下内容添加到过滤器映射中:
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
关于java - 错误页面上不显示西里尔文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9855884/