Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

java - How to write UTF-8 symbols in JSP with Struts 2

I have a list in my action which I field by values saved on a MySql DB.

I only have one object stored, which has designation .

In JSP when I do this:

<s:iterator value="unitesList">
    <s:property value="designation"/>
</s:iterator>
<s:select list="unitesList" name="unity" listValue="designation" listKey="id" />

I have this:

€
<select name="unity" id="unity">
    <option value="1">?</option>
</select>

Why on <s:select> element the element is transformed in a ? ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Place this on the top of the JSP page. Symbols in UTF-8 encoding displays better than ?.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...