0

I need to use unicode in my Spring MVC application and I faced with some troubles. After I submit my hidden form with unicode using jQuery $('.form').submit() data sends to the Spring Controller and there it looks like "%D0%9C%D1%96%D0%B9%20%". In result I can't handle and manipulate with normal string on the server side. What did I do wrong?

I have following form:

<form style="display: hidden" action="${contextPath}/somePage.htm" method="POST" class="form">
    <input type="hidden" class="name" name="name" value=""/>
</form>

And Spring controller:

    @RequestMapping(value = "/somePage", method = RequestMethod.POST)
    public String showSomePage(@RequestParam("name") String name, Model model) {

    }

In my web.xml:

<filter>
    <filter-name>encoding-filter</filter-name>
    <filter-class>
        org.springframework.web.filter.CharacterEncodingFilter
    </filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>encoding-filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

In server.xml of Tomcat:

<Connector URIEncoding="UTF-8" port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
4

1 回答 1

0

固定的。在 POST 方法的情况下,我不必使用 encodeURIComponent() 作为输入值

于 2013-05-28T11:07:27.293 回答