Pinny
Pinny

Reputation: 306

Cyrillic text does not show on error pages

I have a website that should be displayed in two languages: Eng and Ru. It's Tomcat6, Java6, Spring3, Tiles2. Website does show text in both languages. However, if there is an error (and I have setup custom error pages) the error page in Russian text is shown as ????????? (bunch of ?)

The text is in properties files. Thought regular text is in one file, error messages are in the other. I checked - both files are saved using the same encoding.

in my web.xml I do have this:

<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>

and error pages are defined in web.xml as:

<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>

in myApp-servlet.xml I do have this

<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>

And again, entire website does show Russian text correctly. It's the error pages that do not.

Is there a separated setting I need to specify for error pages? Or am I missing something out?

Upvotes: 0

Views: 250

Answers (1)

Konstantin Solomatov
Konstantin Solomatov

Reputation: 10352

There's a parameter in filter-mapping called dispatcher. You should add the following to your filter-mapping:

<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>

Upvotes: 1

Related Questions