官术网_书友最值得收藏!

Configuring custom interceptors

While servlet filters are a part of the Servlet API and have nothing to do with Spring besides being automatically added in the filter chain --Spring MVC provides us with another way of wrapping web requests: HandlerInterceptor. According to the documentation, HandlerInterceptor is just like a filter. Instead of wrapping a request in a nested chain, an interceptor gives us cutaway points at different phases, such as before the request gets handled, after the request has been processed, before the view has been rendered, and at the very end, after the request has been fully completed. It does not let us change anything about the request, but it does let us stop the execution by throwing an exception or returning false if the interceptor logic determines so.

Similar to using filters, Spring MVC comes with a number of premade HandlerInterceptors. The commonly used ones are LocaleChangeInterceptor and ThemeChangeInterceptor; but there are certainly others that provide great value. So let's add LocaleChangeInterceptor to our application in order to see how it is done.

主站蜘蛛池模板: 外汇| 鸡泽县| 景德镇市| 临沂市| 称多县| 调兵山市| 江永县| 新竹县| 偏关县| 广东省| 永福县| 临桂县| 清涧县| 新河县| 紫云| 隆化县| 沂源县| 孟州市| 孟州市| 始兴县| 于都县| 桦川县| 临安市| 蓬溪县| 犍为县| 英德市| 德安县| 温州市| 基隆市| 水富县| 峨眉山市| 株洲县| 建德市| 东乌| 织金县| 来安县| 承德市| 汕头市| 莱芜市| 塘沽区| 祥云县|