Announcement Announcement Module
Collapse
No announcement yet.
spring:bind, text input and international characters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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>

    Comment


    • #3
      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

      Comment


      • #4
        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?

        Comment

        Working...
        X