【发布时间】:2012-02-16 21:33:29
【问题描述】:
我正在使用spring mvc。我正在用希伯来语写作,所以在我的 jsp 表单中,我要求用户用希伯来语给出他的名字。这是表格:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<form:form method="post" action="registration-submit.html">
אנא מלא את הפרטים הבאים בכדי להשלים את הרשמתך:
<table>
<tr>
<td>שם:</td>
<td><form:input path="name" type="text" id="nameInput"/></td>
</tr>
<tr>
<td>סיסמא:</td>
<td><form:input path="password" type="password" id="passwordInput"/></td>
</tr>
<tr>
<td>וידוא סיסמא:</td>
<td><input type="password" id="passwordVerifyInput"/></td>
</tr>
<tr>
<td>דואר אלקטרוני:</td>
<td><form:input path="email" type="text" id="emailInput"/></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="הירשם"/>
</td>
</tr>
</table>
</form:form>
对于registration-submit.html,我有控制器:
@RequestMapping(value = "/registration-submit", method = RequestMethod.POST)
public ModelAndView showRegistrationSubmitPage(
@ModelAttribute("registrationForm") final RegistrationForm registrationForm,
BindingResult result) {
...
...
}
当我将registrationForm.name 添加到手表时,我看到:× ××ר(不可读的字符)而不是希伯来语名称。
jsp 文件以 UTF-8 字符集保存。为什么我会从表单中得到不可读的字符? spring的字符集如何设置?
【问题讨论】:
标签: java spring spring-mvc character-encoding