misco
misco

Reputation: 1952

Wrong encoding for static texts on a JSP page

I have an issue with the encoding on JSP page. I use spring framework with Maven in my project.

I have set the encoding in

Maven

<properties>
    <spring.version>3.0.2.RELEASE</spring.version>
    <cxf.version>2.7.5</cxf.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

Spring

<filter>
    <filter-name>charsetEncodingFilter</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>charsetEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

JSP (through html meta)

<meta http-equiv='content-type' content='text/html;charset=utf-8' />

I tracked returned document from server and its encoding. It is right - UTF-8.

On the JSP page there are :

But I have problem only with static text, it shows texts like ľšÄťžýáíé.

Any ideas for the solving this issue?

Upvotes: 1

Views: 757

Answers (1)

Joop Eggen
Joop Eggen

Reputation: 109557

Evidently the JSP compiler (in your Java EE server) that translates .jsp to .java assumes that the (UTF-8) text is another encoding, and hence those sequences. Use:

<%@ page pageEncoding="UTF-8" %>

Upvotes: 5

Related Questions