Jsp and serlvet Chinese garbled solutions

Source: Internet
Author: User

I. Basic jsp and serlvet Chinese garbled solutions
(The complete solution notes are provided before, and you will not be able to post them if you are free of time)

II. apache commons-fileupload was used as the upload component in October 2011. Garbled code was used to resolve the error when submitting a form field containing fields and files:
1. Same as "1.", use a filter to encode all request requests with UTF-8
2. Solve the garbled characters of form field values:

The code is as follows: Copy code
If (item. isFormField ()){
// If item is a normal form field
String name = item. getFieldName ();
String value = item. getString ("UTF-8"); // solves garbled characters in the values of form fields
     }

3. Solve the garbled path of the uploaded file:
    

The code is as follows: Copy code
FileItemFactory factory = new DiskFileItemFactory ();
ServletFileUpload upload = new ServletFileUpload (factory );
Upload. setHeaderEncoding ("UTF-8"); // solves the path garbled setting of the uploaded file
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.