1

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?

4

4 回答 4

1

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-17T00:45:27.157 回答
0

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-11T11:54:19.613 回答
0

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-11T14:05:28.127 回答
0

You need to use a filter. See:

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

于 2008-10-22T01:52:21.900 回答