Advertisement
Advertisement


Stuts2 Tiles Tomcat suspected of changing UTF-8 to?


Question

I'm having some internationalisation woes:

My UTF-8 string fields are being rendered in the browser as ???? after being returned from the database.

After retrieval from the database using Hibernate, the String fields are presented correctly on inspection using the eclipse debugger.

However Struts2/Tiles is rendering these strings as ???? in the HTML sent to the browser.

The charset directive is present in the HTML header:

Perhaps I need to add something to my struts2 or tiles configurations?

2008/11/05
1
1
11/5/2008 2:38:39 PM

Accepted Answer

You could try something like this.

It's taken from sun's page on Character Sets and Encodings. I think this has to be the very first line in your jsp.

<%@ page contentType="text/html; charset=UTF-8" %>
2008/09/11
0
9/11/2008 2:05:28 PM

OMG - it turns out that the cause was a total WTF?

all our tile responses were being served by a homegrown servlet that was ignoring the

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

directive (and who know what else).

TilesDispatchExtensionServlet : bloody architecture astronauts, i shake my fist at ye.

2008/09/17

Try setting the lang attribute on the <html/> element.

HTML example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja"> 

XHTML example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"> 
2008/09/11

You need to use a filter. See:

http://wiki.apache.org/tomcat/Tomcat/UTF-8

2008/10/22

Source: https://stackoverflow.com/questions/56045
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]