Filter: A Java class that implements the Filter interface. As the name implies, we can use filters to specify strings that cannot appear, to avoid Chinese garbled characters, to verify permissions… Implementation filter

Step1: Code to implement the Filter interface

Step2: deploy the filter


@WebFilter(filterName = “FilterDemo1”,urlPatterns = “/*”)


As mentioned above, there may be multiple filters that perform different functions, and these filters are stored in Java’s chained structure. Note that the order in which the filters are executed is based on the order in which the mapping is performed in the web.xml file. Annotated configuration compares the string priorities of urlPatterns to determine which execution takes place. And the filter is executed first before the end

The above is only an introduction to Filter, and its application has not been written. If there are mistakes welcome to correct, exchange and learn together!