如何使用JSTL / EL显示外来字符? [英] How to show foreign characters using JSTL/EL?
问题描述
我使用JSTL < c:out>
标记来打印外部数据。 $ {data}
包含外来字符。
但它无法正常显示。有没有任何解析器来显示外国字符?
I am printing foreign data using JSTL <c:out>
tag. The ${data}
contains foreign characters.
But it's not showing properly. Is there any parser to show foreign characters? Or any other way?
推荐答案
将这放在您的JSP之上。
Put this in top of your JSPs.
<%@page pageEncoding="UTF-8" %>
它将设置响应编码,并通过适当的响应标头指示webbrowser解释它。
It will set the response encoding and instruct the webbrowser by the proper response headers to interpret it as such.
您只需要确保外部数据采用UTF-8编码。所以如果源是SQL数据库,请确保数据库和表使用UTF-8。或者如果源是文本文件,请确保它已保存并以UTF-8格式读取。
You only need to ensure that "foreign data" is been encoded in UTF-8. So if the source is a SQL database, ensure that the DB and table use UTF-8. Or if the source is a text file, ensure that it's been saved and read as UTF-8.
- Unicode - How to get the characters right?
这篇关于如何使用JSTL / EL显示外来字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!