Filter: filtration ; filter;
At present, the main application of Java is the Web project, so it will face a variety of data access and requests, so filtering is necessary, like a human lungs, need to be beneficial to the human body left in the body, unfavorable exclusion in vitro.
Mr. Ma's lecture on Javawebfilter is a classic, at least in my opinion, and it's easy for students to understand his principles.
Off topic: java, so beautiful!!!
Here are some extensibility aspects to summarize performance: from A-e step by step.
Premise: The content of filtering msg= "***********************";
The first: A, replacing the specific contents of the MSG directly in the main method.
The second type: B, filtering by uniformly implementing the filter interface to encapsulate the Xxxfilter class.
The third type: C, the Xxxfilter through the filter interface into the list of filter, the implementation of one time to add multiple reuse.
The fourth type: D, create Filterchain to combine the filter's list, filter, etc. freely.
The fifth type: E, through Javawebfilter dofilter (request,response,chain) to realize how the msg from the outside filter to inside, and then filtered from inside to outside.
OK, that's the general course, and the Code section can be found online.
Washing clothes, sleeping ....
The responsibility chain----the Java design pattern Filter