Pagination Technical Framework (PAGER-TAGLIB) learning three (Chinese garbled problem when passing parameters in Pager-taglib)

Source: Internet
Author: User

First, the problem description

Problem:

When using <pg:param name= "key"/> Tag to pass Chinese parameters, there will be garbled characters.

Reason:

Because it is the default to use gb2312 to encode the added parameters, if your filter, JSP pages are used gb2312 There is no problem, if you are using Utf-8 to encode , Then the Chinese parameter passing the process will be garbled, resulting in unresolved.

Second, problem solving methods

There are many solutions on the web, and it is a good idea to re-modify the compiled source code:

In the AddParam of Pagertag under Com\jsptags\navigation\pager (string name, String value), It originally used the urlencoding.encode (value) method to encode the passed parameters, modified to become urlencoding.encode (value, "UTF-8"), Replace this class file with the original jar package and repackage it into the project.

1. First Extract the files from the Pager-src.jar .

You can see there's two files in there.

2. Create an empty Javaproject project in Eclipse , name pager-taglib,

Copy the two files you extracted above

3. because some of the classes in javax.servlet.* are used in the above class

So to import the Javaee.jar package

If you are in myeclipse , import the javaee5 jar package directly, or import the entire Java EE 5Libraries


4. then modify

In the AddParam of Pagertag under Com\jsptags\navigation\pager (string name, String value), It originally used the urlencoding.encode (value) method to encode the passed parameters, modifying it to become Urlencoding.encode (value, "UTF-8"). Of course urlencoding.encode (name) can also be modified to Urlencoding.encode (name, "UTF-8") and finally use Try/catch for exception snapping

5. Export the jar package

Export--->java---->java jarfile- lead jar package

6. re-import into the Web project

Pagination Technical Framework (PAGER-TAGLIB) learning three (Chinese garbled problem when passing parameters in Pager-taglib)

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.