Wisdom Podcast Javaweb day14--Listener (User kick), filter (solve the whole station garbled)

Source: Internet
Author: User

1.

2.

3.

4.

5.

Filter application

1. Using filters to solve the whole station garbled problem

1.1 Garbled categories

Garbled into get and post way request garbled

1.2 Post request garbled solution

Post request garbled good solution just one line of code to fix request.setcharacterencoding ("Utf-8") tells the server to use Utf-8 to get the parameters

1.3 Get Request garbled solution

Problem: Cannot solve the garbled problem for a parameter, because the filter is general-purpose, the other request may not have this parameter, so think of the transformation to get the request parameters of the three methods, and the way of direct inheritance there are many ways to achieve their own, So inherit Httpservletrequestwrapper (an adorner class, all calls the method of the decorated object itself), and then transform the three methods to get the parameters

1.3.1 Implementation Getparametermap ()

1.4 Supplement

    1.4..1 How to implement a filter the first step is to implement the filter interface (Chain.dofilter method release); The second step is to register in Web. XML, including the filter node and the mapping node

1.4.2 Gets the request parameter method has several getparameter,getparametermap,getparametervalues (PS: If these three methods garbled problem solves, then obtains the request garbled problem also solves)

1.4.3 How to transform a method in a class there are several ways to inherit, adorners, dynamic proxies

Wisdom Podcast Javaweb day14--Listener (User kick), filter (solve the whole station garbled)

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.