IT Band of Brothers JavaWeb tutorials filter 2

3 sequentially performs a plurality of filters

If a Web application uses a filter can not solve practical business needs, then you can deploy multiple filters of the service request processing times, to do so would constitute a filter chain. Web server when the filter chain, the order of the filter will process the request. as shown in picture 2.

1b5c68f948914832b1e7c68403082d70.png

The execution order of the plurality of filters of FIG. 2

 

If the filter is deployed in the chain Web window, which is deployed a plurality of filters, a request will be processed sequentially by the filter, the first filter after a request is processed, it passes to the second filters processing, and so on, until the last one has been passed to the filter, and then the target resource request to be processed. After the processing target resource request filtered response, the response and then passed from the last time to the first filter a filter, and finally to the client, which is application flow filters in the filter chain.

 

4 the advantage of the filter

If multiple Web components written in the program code that the same operation, obviously leads to repetition coding, which reduces software development efficiency and maintainability. Using filters, can be placed in the same individual Web gradually to complete the operation in the same filter, so that we can reduce the repetition coding.

Another advantage is that the filter may be increased without changing the functionality of the program source code at the same time.

Guess you like

Origin www.cnblogs.com/itxdl/p/10954106.html