我正在使用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字符集保存。为什么我从表格中得到不可读的字符?如何设置春天的字符集?

最佳答案

尝试在web.xml中注册CharacterEncodingFilter

关于java - Spring 的MVC字符集,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9319429/

10-10 20:19
查看更多