views:

219

answers:

1

Hello,

I'm trying to use UTF-8 encoding for the Spring application I'm developing but I have problems in getting the correct encoding when inserting attributes from tiles.

I have this fragment in my JSP template:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <title><tiles:getAsString name="title" /></title>   
</head>
<body>
    <tiles:insertAttribute name="header" ignore="true" />
....

and in my tiles XML config file I have something like:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
   "http://tiles.apache.org/dtds/tiles-config_2_1.dtd"&gt;
<tiles-definitions>
   <definition name="tiles:base" template="/WEB-INF/views/templates/main.jsp">
     <put-attribute name="title" value="Título" />
...

I have check in eclipse that this files have UTF-8 encoding. The word passed in title attribute is not shown correctly (the accented characters are shown in a wrong way) in the page though the rest of the JSP is correct (for instance the JSP fragment which is inserted in header). If I change the encoding to ISO-8859-1 the title is OK, but the rest odf the page is wrong. It seems I cannot get to change the encoding to UTF-8 in my tiles file. I have also looked for "ISO-8859-1" in the files I've created and I haven't set up this configuration in any file.

Can anyone tell me how can I set up the correct encoding for tiles?

Thanks

A: 

It was a problem with the charset, not with the encoding. I had to set

<%@ page contentType="text/html; charset=utf-8"%> 

in every JSP and it worked. I don't know if there is an easier way of configure this in all the JSPs of a Spring Web application.

Javi