Announcement Announcement Module
Collapse
No announcement yet.
Roo Encoding issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo Encoding issue

    Hello,

    When generating a simple web project it seems that the encoding is somehow broken, at least on my computer.

    It seems that it doesn't sent data in UTF-8 format, so the special characters (such as etc.) cannot be interpreted correctly.

    I tried a simple web project and tested with System.out.println(""); without luck, and also a Spring-Flex project:
    When accessing the exposed AMF service from Flex, the character encoding is also broken.

    Needless to say that everything is set to use UTF-8 (Maven,Tomcat, Hibernate, Eclipse workspace), and that everything works as expected if NOT using Roo.

    Windows 7 x64
    STS 2.5.2 32bit
    Roo 1.1.1.RELEASE
    Maven 3.0.2

    Anyone else having similar issues ?

  • #2
    Re: Roo Encoding issue

    Hello Astronaute,

    I'm working with a simple jspx, spring, hibernate project and have the same issue. I use characters like , , , , , .

    My issues are in:
    * Inputs fields in post actions
    * Labels code in message.properties and applications.properties files.

    I try solve this with replace all "ISO-8859-1" to "UTF-8" in all .jspx and .xml files in the project, and a lot of tomcat files with same string.

    My development environment is:
    Linux Mint 9 x64
    STS 2.5.0 32bit
    Roo 1.1.0.RELEASE
    Maven 3.0-SNAPSHOT

    Please help us!!

    Comment


    • #3
      Hello,
      is there any update on this?
      We are having the same problem.

      thanks & best,
      Milan

      Comment


      • #4
        Hi folks,
        I've experienced such problem using MySQL... In default generated project all special characters wrote to DB as "???"

        Update database.properties with
        database.url=jdbc\:mysql\://localhost\:3306/[YOUR_DB_NAME]?autoReconnect\=true&useUnicode\=true&characterEnc oding\=UTF-8

        Comment


        • #5
          Originally posted by Tigra View Post
          Hi folks,
          I've experienced such problem using MySQL... In default generated project all special characters wrote to DB as "???"

          Update database.properties with
          As I already stated, even the simple...
          Code:
          System.out.println("");
          ... is broken, it has nothing to do with the database, which btw is set to UTF-8 as is everything else on my computer, so it is definitely a Roo issue*

          Comment


          • #6
            just to confirm that

            database.url=jdbc\:mysql\://localhost\:3306/[YOUR_DB_NAME]?autoReconnect\=true&useUnicode\=true&characterEnc oding\=UTF-8

            fixed our issue with encoding.

            thanks Tigra,
            best,
            Milan

            Comment


            • #7
              Originally posted by clandestino_bgd View Post
              just to confirm that



              fixed our issue with encoding.

              thanks Tigra,
              best,
              Milan
              Clandestino: in my mysql the encoding is working perfect. My problem is from the POST to the method in the controller class for example:

              In the page I write "" in a input box, and do a post
              In the controller, the input box content is "ééé" the problem persist with bind with a bean as controller method parameter.

              I patched this with a corrector method, but it's only working in the post to server and if the string content is in lowercase()

              st = st.replaceAll("á", "");
              st = st.replaceAll("é", "");
              st = st.replaceAll("*", "");
              st = st.replaceAll("ó", "");
              st = st.replaceAll("ú", "");
              st = st.replaceAll("ñ", "");

              Comment


              • #8
                Djorco,
                I don't know what to suggest apart from already reported on forum and jira.
                Basically 3 things need to be done:
                1. database url in database properties
                2. character encoding filter mapping as first in web.xml
                3. your database charset is UTF-8

                With those we don't have any problem submitting german and russian characters in roo generated forms.

                hth,
                Milan

                Comment


                • #9
                  Originally posted by clandestino_bgd View Post
                  Djorco,
                  I don't know what to suggest apart from already reported on forum and jira.
                  Basically 3 things need to be done:
                  1. database url in database properties
                  2. character encoding filter mapping as first in web.xml
                  3. your database charset is UTF-8

                  With those we don't have any problem submitting german and russian characters in roo generated forms.

                  hth,
                  Milan
                  Milan I do appreciate your help but as already repeated several times, it has nothing to do with database charset as this problem occurs even without any database.

                  You and Tigra probably have different problem, Tigra said he has "????" and not "é" so it is not same encoding issue. You had encoding "from" UTF-8 issue, Djorco and me have "to" UTF-8 issue.

                  Comment


                  • #10
                    Originally posted by clandestino_bgd View Post
                    Djorco,
                    1. database url in database properties
                    3. your database charset is UTF-8
                    It's OK

                    Originally posted by clandestino_bgd View Post
                    Djorco,
                    2. character encoding filter mapping as first in web.xml
                    this is the character enconding filter section in the web.xml


                    <filter>
                    <filter-name>CharacterEncodingFilter</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>
                    <init-param>
                    <param-name>forceEncoding</param-name>
                    <param-value>true</param-value>
                    </init-param>
                    </filter>


                    But the encoding issue persist. I'm submitting spanish characters

                    Comment


                    • #11
                      Just to note:
                      This had been mentioned previously but it should be fixed actually!
                      https://jira.springsource.org/browse/ROO-1684
                      https://jira.springsource.org/browse/ROO-1731

                      So, if you didn't "play" with the order of <filter-mapping> in web.xml you shouldn't stumble over this issue anymore. Does it still occur?

                      Cheers
                      Alex

                      Comment


                      • #12
                        <filter-mapping> not <filter> order is relevant, according to one comment in JIRA. Can you try that?

                        Comment


                        • #13
                          I reached a solution by rearranging the tags filter and filter-mapping in the web.xml file as shown below:


                          <filter>
                          <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
                          <filter-class>org.springframework.orm.jpa.support.OpenEnti tyManagerInViewFilter</filter-class>
                          </filter>
                          <filter>
                          <filter-name>CharacterEncodingFilter</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>
                          <init-param>
                          <param-name>forceEncoding</param-name>
                          <param-value>true</param-value>
                          </init-param>
                          </filter>
                          <filter>
                          <filter-name>HttpMethodFilter</filter-name>
                          <filter-class>org.springframework.web.filter.HiddenHttpMet hodFilter</filter-class>
                          </filter>
                          <filter>
                          <filter-name>springSecurityFilterChain</filter-name>
                          <filter-class>org.springframework.web.filter.DelegatingFil terProxy</filter-class>
                          </filter>


                          <filter-mapping>
                          <filter-name>CharacterEncodingFilter</filter-name>
                          <url-pattern>/*</url-pattern>
                          </filter-mapping>
                          <filter-mapping>
                          <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
                          <url-pattern>/*</url-pattern>
                          </filter-mapping>
                          <filter-mapping>
                          <filter-name>springSecurityFilterChain</filter-name>
                          <url-pattern>/*</url-pattern>
                          </filter-mapping>
                          <filter-mapping>
                          <filter-name>HttpMethodFilter</filter-name>
                          <url-pattern>/*</url-pattern>
                          </filter-mapping>


                          And it's work fine. I'm really happy

                          Astronaute prove with this changes to confirm the same solution.

                          thanks clandestino_bgd and aheusingfeld for helping us reach a solution

                          Comment


                          • #14
                            Glad to see it works, I'll check this ASAP, probably tomorrow and comment here

                            Thank you all.

                            Comment


                            • #15
                              Just a note as I ran into a problem with this last year:

                              In case you want to use Spring Security with HTTP method in intercept-url like the following
                              Code:
                              	<!-- HTTP security configurations -->
                                  <http auto-config="true" use-expressions="true">
                                  	<form-login login-processing-url="/static/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t"/>
                                      <logout logout-url="/static/j_spring_security_logout"/>
                              
                                      <!-- Configure these elements to secure URIs in your application -->
                                      <intercept-url pattern="/**" method="DELETE" access="hasRole('ROLE_SYSADMIN')"/>
                                      <intercept-url pattern="/admin/**/form" access="hasRole('ROLE_ADMIN_EDITOR') or hasRole('ROLE_SYSADMIN')"/>
                                      <intercept-url pattern="/order/**" access="hasRole('ROLE_ORDER_VIEWER') or hasRole('ROLE_ORDER_EDITOR') or hasRole('ROLE_SYSADMIN')" />
                                      <intercept-url pattern="/resources/**" access="permitAll" />
                                      <intercept-url pattern="/static/**" access="permitAll" />
                                      <intercept-url pattern="/**" access="permitAll" />
                                      <session-management session-fixation-protection="newSession"/>
                                  </http>

                              you have to switch the order of the last two filter mappings:
                              Code:
                              <filter-mapping>
                                  <filter-name>CharacterEncodingFilter</filter-name>
                                  <url-pattern>/*</url-pattern>
                              </filter-mapping>
                              <filter-mapping>
                                  <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
                                  <url-pattern>/*</url-pattern>
                              </filter-mapping>
                              <filter-mapping>
                                  <filter-name>HttpMethodFilter</filter-name>
                                  <url-pattern>/*</url-pattern>
                              </filter-mapping>
                              <filter-mapping>
                                  <filter-name>springSecurityFilterChain</filter-name>
                                  <url-pattern>/*</url-pattern>
                              </filter-mapping>
                              The reason is that HTML forms do always send data via POST or GET. As a workaround Spring MVC uses a hidden formfield supplying the intended HTTP method which is parsed by HttpMethodFilter.

                              Happy Hacking!

                              Cheers
                              Alex

                              Comment

                              Working...
                              X