The form submission method is changed from post to get and garbled.

Source: Internet
Author: User

The combined query function is originally submitted using the <HTML: Form> POST method by default. After the paging function is added, the user-submitted query content (for example, http: // localhost: 8080/aims/client/filter. do? Name = % E5 % BC % A0 & Address = % E5 % 8C % 97% E4 % Ba % AC & Title = & duty = & departmentcode = 10000001 & categorycode = 10000002 & fieldcode = 10000006 & amp; gendercode = & amp; identitycode = ), therefore, the form submission method should be changed to get.

Simply change to method = "get", but this change makes the action unable to get the correct input value. For example, if you enter "Zhang" in the name condition, use theform in the action. getname () will get garbled characters such as "% A4". Not only are the query results incorrect, but garbled characters are also displayed in the name column of the re-display query form.

I tried a lot of transcoding is not converted into the original value, asked a lot of friends, the final solution is still through the conversion of encoding, is to convert the ISO8859-1 to UTF-8, that is, string name = new string (theform. getname (). getbytes ("ISO8859-1"), "UTF-8");, pay attention to my applicationsProgramThe encoding filter for the UTF-8 is used.

Although manual transcoding is requiredCodeIt's not good, but it's only here. My current environment is Tomcat + MySQL. I don't know if there will be any garbled code on another server. Fortunately, this issue does not need to be considered in this project.

It is said that Tomcat processes post and get requests in a different way. in XML, the <connector> Add uriencoding = "GBK" attribute, but I try to make a difference.

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.