Announcement Announcement Module
Collapse
No announcement yet.
form:input not showing correctly UTF-8 chars Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • form:input not showing correctly UTF-8 chars

    Hi everybody there,
    i'm dealing with a web application that uses spring MVC tags and simpleFormControllers to save some form data from a jsp page.

    I try to describe the problem i get when a user sets an input with a non-standard character (like ĕ, corresponding to UTF-8 & #277; ).

    After posting the form, the character is correctly saved to postgres database in UTF-8 format (i'm using iBatis DAOs).
    If i enter into the form again, the form:input fields are filled with values contained with database: i see into the input the UTF-8 format instead of the "real" character.
    The strange thing is that if i try to output the field value without using form:input tags, (using into the jsp the EL language, e.g. ${command.fieldName}), i see the character ĕ displayed correctly.

    The <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> has already been added to the top of the page and i tried to add into my web.xml the following xml:
    <filter>
    <filter-name>charEncFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEnco dingFilter</filter-class> <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>charEncFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>


    But unfortunately it still doesn't work.

    Any ideas?

    thanks a lot
    M

  • #2
    Originally posted by kantorn
    Could it have some connection to the database's character encoding settings?
    Now i added to "form:form" tag this:
    enctype="UTF-8" acceptCharset="UTF-8"


    While before that (i think it was wrong) it saved the utf-8 representation into the database table, now, looking with pgAdmin, i see the correct character "ĕ" saved in. But if i reload the form, it shows a "?" instead of that char.
    It seems like the web page is not able to show me the UTF-8 char.

    Any suggestions?

    Comment


    • #3
      solved!

      Originally posted by musmarc View Post
      Now i added to "form:form" tag this:
      enctype="UTF-8" acceptCharset="UTF-8"
      All solved!
      The page wasn't correctly setting the encode type due to a wrong position of the <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>.

      There is no need at all to add those properties to the form:form tag... it works however.

      cheers
      M

      Comment


      • #4
        Thanks Every one, great post, resolved my issue too.

        Comment


        • #5
          Freemarker utf problem

          Hi,

          Could you please clarify what exactly you meant by the position was wrong in

          "The page wasn't correctly setting the encode type due to a wrong position of the <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>."

          I have the same problem. I have added meta tag like this "<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>" in my ftl page but it still doesn't work.

          Any help greatly appreciated!

          Comment

          Working...
          X