cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "roy huang" <lingererhu...@hotmail.com>
Subject requestparameter encoding problem(was:[Help]Encoding problem with form+ajax in current svn)
Date Thu, 10 Nov 2005 06:37:47 GMT
Hi,all:
  I have solved the problem,it's requestparameter's encoding again.
  I remember someone mentioned double encoding problem in mail list,I didn't remember the
list,the problem now is:
  When I use Cocoon Forms to display and input Chinese,I use UTF-8,so serializer encoding
set to utf-8,form encoding set to utf-8,container encoding set to iso-8859-1,all is fine.But
Ajax using js encodingURIComponent to encode value and combine it as querystring to post to
the server.So if two Chinese word 测试,in the first condition it will encode direct to
utf-8 but in the Ajax condition it became &contacts.0.firstname=%20%E6%B5%8B%E8%AF%95<---here.
  So,the web server(tomcat or jetty) decode %20%E6%B5%8B%E8%AF%95 direct to 测试,and then
cocoon decode 测试 in iso-8859-1 and then encode it back to UTF-8,result to ??.
  I can change container encoding from ISO-8859-1 to UTF-8,then Ajax mode works,but original
Form mode doesn't.

  Finally I decide to write a action copy from org.apache.action.setCharacterEncodingAction.java,setting
request's container encoding,and change my sitemap from:
   <map:match pattern="continue">
         <map:call continuation="{request-param:continuation-id}"/>
    </map:match>

to
   <map:match pattern="continue">
      <map:select type="ajax-request">
       <map:when test="true">
      <map:act type="container-encoding">
        <map:parameter name="container-encoding" value="utf-8" />
       </map:act>
       </map:when>
       </map:select>
         <map:call continuation="{request-param:continuation-id}"/>
    </map:match>
and the attachment is my java file.

  Are there any other ways?Please comment your suggestion.

Roy Huang
Mime
View raw message