Results 1 to 4 of 4

Thread: spring:bind, text input and international characters

  1. #1
    Join Date
    Feb 2011
    Posts
    6

    Default spring:bind, text input and international characters

    Hi!
    I'm having the following problem.

    I want to use international characters (Russian, chineese etc) in my JSP page (encoding is set to UTF-8) in text input like:
    Code:
    <spring:bind path="myCompany.name">
    <input type="text" value="<c:out value="${status.value}"/>" id="<c:out value="${status.expression}"/>" name="<c:out value="${status.expression}"/>"/>
    </spring:bind>
    When i type for example russian characters "Россия" into this text input and click SUBMIT button, then command parameter in onSubmit callback contains corrupted characters: "Ð*оÑ�Ñ�иÑ�".

    Also if JSP page has bind errors then this text input will contain the same corrupted value: "Ð*оÑ�Ñ�иÑ�".

    What's wrong? Please help! I'm new to spring and spring MVC.

  2. #2
    Join Date
    Feb 2011
    Posts
    6

    Default

    All fixed.
    I added CharacterEncoding filter to web.xml:
    Code:
    <!--
        - This is useful because current browsers typically do not
        - set a character encoding even if specified in the HTML page or form
     -->
     <filter>
        <filter-name>encodingFilter</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>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
     </filter-mapping>

  3. #3
    Join Date
    May 2012
    Posts
    1

    Unhappy

    Quote Originally Posted by decadance View Post
    All fixed.
    I added CharacterEncoding filter to web.xml:
    Hi I'm facing the same problem. I added the org.springframework.web.filter.CharacterEncodingFi lter in web.xml. But still I couldn't resolve. Could you please let me know what are all things required otherthan what you have mentioned.
    Thank you,
    mk

  4. #4
    Join Date
    May 2011
    Location
    Chennai
    Posts
    2

    Default

    Quote Originally Posted by mk4uspring View Post
    Hi I'm facing the same problem. I added the org.springframework.web.filter.CharacterEncodingFi lter in web.xml. But still I couldn't resolve. Could you please let me know what are all things required otherthan what you have mentioned.
    Thank you,
    mk
    have you set encoding type in your jsp?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •