Issue of garbled Chinese Characters in WAP input written in JSP

Source: Internet
Author: User

 

1. <% response. setcontenttype ("text/vnd. WAP. WML; charset = UTF-8"; %> // utf8
2. <% request. setcharacterencoding ("UTF-8"; %> // parameter processing method utf8
3. <% @ page pageencoding = "ISO-8859-1" %> // page Character Handling Method iso-8859-1

My JSP Example:

Input page test1.jsp:

1. <% @ page contenttype = "text/vnd. WAP. WML; charset = gb2312" %>
2. <% @ page pageencoding = "ISO-8859-1" %>
3. <? XML version = "1.0"?>
4. <! Doctype WML public "-// wapforum // dtd wml 1.1 // en ""Http://www.wapforum.org/DTD/wml_1.1.xml">
5. <WML>
6. <card id = "test1" Title = "Chinese Character Input">
7. <p>
8. Name <input name = "name" size = "10"/> <br/>
9. Number <input name = "ID" format = "* n" size = "12"/> <br/>
10.
11. <anchor> OK
12. <go href = "test2.jsp" method = "Post">
13. <postfield name = "name" value = "name"/>
14. <postfield name = "ID" value = "ID"/>
15.
16. </go>
17. </anchor>
18. </card>
19. </WML>

// The above uses the go method = "Post"> method to transmit parameters. It does not seem to work with get.

Receiving page test2.jsp:

1. <% @ page contenttype = "text/vnd. WAP. WML; charset = UTF-8" %>
2. <? XML version = "1.0"?>
3. <! Doctype WML public "-// wapforum // dtd wml 1.1 // en ""Http://www.wapforum.org/DTD/wml_1.1.xml">
4. <WML>
5. <card id = "Test2" Title = "Chinese Character receiving">
6. <%
7. Request. setcharacterencoding ("UTF-8 ";
8. string name = request. getparameter ("name ";
9. String id = request. getparameter ("ID ";
10. %>
11. <p> name: <% = Name %> </P>
12. <p> ID: <% = ID %> </P>
13.
14. <do type = "Prev" label = "back to previous page">
15. <Prev/>
16. </DO>
17.
18. </card>
19. </WML>

Save the two files as UTF-8 files.
My main feeling is
Request. setcharacterencoding ("UTF-8 ″;
If the input page is in gb2312 format
To accept the page, use
Request. setcharacterencoding ("gb2312 ″;
We recommend that you use UTF-8 because the mobile gateway uses UTF-8.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.