You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/03/06 06:49:46 UTC

T5: Chinese in form submission(5.0.11)

Hi,

I have a simple form just to accept anything, but when I encode some chinese
characters, it turns out garbage in the server side, why?

<head>
    <title>Start Page</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>

    <t:form>

        <input t:type="textfield" t:id="msg" value="msg"></input>
         <input type="submit"  value="submit" />

    </t:form>

jave side:

 void onSubmit() {
        System.out.println(msg);
    }


-- 
View this message in context: http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15866978.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Chinese in form submission(5.0.11)

Posted by yuan gogo <go...@gmail.com>.
Thank you. Your way is right!


2008/3/11, Yoshikazu Kuramochi <yo...@kuramo.ch>:
>
> The same problem occurs by using japanese characters.
>
> org.apache.tapestry.upload.internal.services.MultipartServletRequestFilt
> er
> is executed before the Utf8Filter written in the wiki page.
> So request.getCharacterEncoding() returns null
> in org.apache.tapestry.upload.internal.services.MultipartDecoderImpl,
> and the default character encoding is used to decode field values.
>
> As follows I resolved the problem:
>
>      * Utf8Filter implements HttpServletRequestFilter, instead of
> RequestFilter.
>      * Add the filter before MultipartFilter.
>
>
>      public HttpServletRequestFilter buildUtf8Filter()
>      {
>          return new HttpServletRequestFilter()
>          {
>              public boolean service(HttpServletRequest request,
> HttpServletResponse response,
>                      HttpServletRequestHandler handler) throws
> IOException
>              {
>                  request.setCharacterEncoding("UTF-8");
>                  return handler.service(request, response);
>              }
>          };
>      }
>
>      public void contributeHttpServletRequestHandler(
>              OrderedConfiguration<HttpServletRequestFilter>
> configuration,
>              @InjectService("Utf8Filter")
>              HttpServletRequestFilter utf8Filter)
>      {
>          configuration.add("Utf8Filter", utf8Filter,
> "before:MultipartFilter");
>
>      }
>
>
>
> On 2008/03/11, at 11:03, Angelo Chen wrote:
>
> >
> > Hi Yuan,
> >
> > I'm not using Spring, will this work too?
> >
> >
> > yuan gogo wrote:
> >>
> >> I use spring.
> >> And config it in web.xml
> >>
> >>     <filter>
> >>         <filter-name>SetCharacterEncoding</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>
> >>     </filter>
> >>     <filter-mapping>
> >>         <filter-name>SetCharacterEncoding</filter-name>
> >>         <url-pattern>/*</url-pattern>
> >>     </filter-mapping>
> >>
> >> This makes the text fields with file-upload work in correctly!
> >>
> >>
> >>
> >> 2008/3/7, Angelo Chen <an...@yahoo.com.hk>:
> >>>
> >>>
> >>> Hi Yuan,
> >>>
> >>> yes, the problem now is, file upload, if you have a textfield
> >>> mixed with
> >>> file upload, the input will have garbage.
> >>>
> >>>
> >>>
> >>> yuan gogo wrote:
> >>>>
> >>>> This problem has been resolved.
> >>>>
> >>>> I'm Chinese too :-)
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >>> http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%
> >>> 29-tp15866978p15890060.html
> >>>
> >>> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>> --------------------------------------------------------------------
> >>> -
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>
> >>
> >
> > --
> > View this message in context: http://www.nabble.com/T5%3A-Chinese-
> > in-form-submission%285.0.11%29-tp15866978p15973133.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: Chinese in form submission(5.0.11)

Posted by Yoshikazu Kuramochi <yo...@kuramo.ch>.
The same problem occurs by using japanese characters.

org.apache.tapestry.upload.internal.services.MultipartServletRequestFilt 
er
is executed before the Utf8Filter written in the wiki page.
So request.getCharacterEncoding() returns null
in org.apache.tapestry.upload.internal.services.MultipartDecoderImpl,
and the default character encoding is used to decode field values.

As follows I resolved the problem:

     * Utf8Filter implements HttpServletRequestFilter, instead of  
RequestFilter.
     * Add the filter before MultipartFilter.


     public HttpServletRequestFilter buildUtf8Filter()
     {
         return new HttpServletRequestFilter()
         {
             public boolean service(HttpServletRequest request,  
HttpServletResponse response,
                     HttpServletRequestHandler handler) throws  
IOException
             {
                 request.setCharacterEncoding("UTF-8");
                 return handler.service(request, response);
             }
         };
     }

     public void contributeHttpServletRequestHandler(
             OrderedConfiguration<HttpServletRequestFilter>  
configuration,
             @InjectService("Utf8Filter")
             HttpServletRequestFilter utf8Filter)
     {
         configuration.add("Utf8Filter", utf8Filter,  
"before:MultipartFilter");
     }



On 2008/03/11, at 11:03, Angelo Chen wrote:

>
> Hi Yuan,
>
> I'm not using Spring, will this work too?
>
>
> yuan gogo wrote:
>>
>> I use spring.
>> And config it in web.xml
>>
>>     <filter>
>>         <filter-name>SetCharacterEncoding</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>
>>     </filter>
>>     <filter-mapping>
>>         <filter-name>SetCharacterEncoding</filter-name>
>>         <url-pattern>/*</url-pattern>
>>     </filter-mapping>
>>
>> This makes the text fields with file-upload work in correctly!
>>
>>
>>
>> 2008/3/7, Angelo Chen <an...@yahoo.com.hk>:
>>>
>>>
>>> Hi Yuan,
>>>
>>> yes, the problem now is, file upload, if you have a textfield  
>>> mixed with
>>> file upload, the input will have garbage.
>>>
>>>
>>>
>>> yuan gogo wrote:
>>>>
>>>> This problem has been resolved.
>>>>
>>>> I'm Chinese too :-)
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11% 
>>> 29-tp15866978p15890060.html
>>>
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> -------------------------------------------------------------------- 
>>> -
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/T5%3A-Chinese- 
> in-form-submission%285.0.11%29-tp15866978p15973133.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Chinese in form submission(5.0.11)

Posted by yuan gogo <go...@gmail.com>.
Maybe you can try this
http://wiki.apache.org/tapestry/Tapestry5Utf8Encoding

2008/3/11, Angelo Chen <an...@yahoo.com.hk>:
>
>
> Hi Yuan,
>
> I'm not using Spring, will this work too?
>
>
>
> yuan gogo wrote:
> >
> > I use spring.
> > And config it in web.xml
> >
> >     <filter>
> >         <filter-name>SetCharacterEncoding</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>
> >     </filter>
> >     <filter-mapping>
> >         <filter-name>SetCharacterEncoding</filter-name>
> >         <url-pattern>/*</url-pattern>
> >     </filter-mapping>
> >
> > This makes the text fields with file-upload work in correctly!
> >
> >
> >
> > 2008/3/7, Angelo Chen <an...@yahoo.com.hk>:
> >>
> >>
> >> Hi Yuan,
> >>
> >> yes, the problem now is, file upload, if you have a textfield mixed
> with
> >> file upload, the input will have garbage.
> >>
> >>
> >>
> >> yuan gogo wrote:
> >> >
> >> > This problem has been resolved.
> >> >
> >> > I'm Chinese too :-)
> >> >
> >> >
> >> >
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15890060.html
> >>
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
>
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15973133.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: Chinese in form submission(5.0.11)

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Yuan,

I'm not using Spring, will this work too?


yuan gogo wrote:
> 
> I use spring.
> And config it in web.xml
> 
>     <filter>
>         <filter-name>SetCharacterEncoding</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>
>     </filter>
>     <filter-mapping>
>         <filter-name>SetCharacterEncoding</filter-name>
>         <url-pattern>/*</url-pattern>
>     </filter-mapping>
> 
> This makes the text fields with file-upload work in correctly!
> 
> 
> 
> 2008/3/7, Angelo Chen <an...@yahoo.com.hk>:
>>
>>
>> Hi Yuan,
>>
>> yes, the problem now is, file upload, if you have a textfield mixed with
>> file upload, the input will have garbage.
>>
>>
>>
>> yuan gogo wrote:
>> >
>> > This problem has been resolved.
>> >
>> > I'm Chinese too :-)
>> >
>> >
>> >
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15890060.html
>>
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15973133.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Chinese in form submission(5.0.11)

Posted by yuan gogo <go...@gmail.com>.
I use spring.
And config it in web.xml

    <filter>
        <filter-name>SetCharacterEncoding</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>
    </filter>
    <filter-mapping>
        <filter-name>SetCharacterEncoding</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

This makes the text fields with file-upload work in correctly!



2008/3/7, Angelo Chen <an...@yahoo.com.hk>:
>
>
> Hi Yuan,
>
> yes, the problem now is, file upload, if you have a textfield mixed with
> file upload, the input will have garbage.
>
>
>
> yuan gogo wrote:
> >
> > This problem has been resolved.
> >
> > I'm Chinese too :-)
> >
> >
> >
>
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15890060.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: Chinese in form submission(5.0.11)

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Yuan,

yes, the problem now is, file upload, if you have a textfield mixed with
file upload, the input will have garbage.


yuan gogo wrote:
> 
> This problem has been resolved.
> 
> I'm Chinese too :-)
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15890060.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Chinese in form submission(5.0.11)

Posted by yuan gogo <go...@gmail.com>.
This problem has been resolved.

I'm Chinese too :-)

2008/3/6, Angelo Chen <an...@yahoo.com.hk>:
>
>
> This problem is fixed by following the utf8 how to in the wiki page. the
> problem now is, the form's field and file upload, it turned into garbage.
> any fix on this? thanks.
>
>
> Angelo Chen wrote:
> >
> > Hi,
> >
> >
>
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15867597.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5: Chinese in form submission(5.0.11)

Posted by Angelo Chen <an...@yahoo.com.hk>.
This problem is fixed by following the utf8 how to in the wiki page. the
problem now is, the form's field and file upload, it turned into garbage.
any fix on this? thanks.


Angelo Chen wrote:
> 
> Hi,
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Chinese-in-form-submission%285.0.11%29-tp15866978p15867597.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org