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

Configuring custom servlet filters

In a real-world web application, we almost always find a need to add facades or wrappers to service requests, to log them, filter out bad characters for XSS, perform authentication, and so on. Out of the box, Spring Boot automatically adds OrderedCharacterEncodingFilter and HiddenHttpMethodFilter, but we can always add more. Let's see how Spring Boot helps us achieve this task.

Among the various assortments of Spring Boot, Spring Web, Spring MVC, and others, there is already a vast variety of different servlet filters that are available and all we have to do is define them as beans in the configuration. Let's say that our application will be running behind a load balancer proxy and we would like to translate the real request IP that is used by the users instead of the IP from the proxy when our application instance receives the request. Luckily, Apache Tomcat 8 already provides us with an implementation: RemoteIpFilter. All we will need to do is add it to our filter chain.

主站蜘蛛池模板: 察雅县| 林甸县| 信丰县| 会理县| 肥东县| 砚山县| 调兵山市| 余姚市| 乡城县| 富川| 无棣县| 罗源县| 进贤县| 嘉黎县| 措美县| 聂拉木县| 洪洞县| 沧州市| 通河县| 郑州市| 平湖市| 遂宁市| 长子县| 永兴县| 山东省| 铜鼓县| 仁布县| 中超| 琼海市| 句容市| 武强县| 周至县| 石林| 南平市| 兰溪市| 滕州市| 茌平县| 昔阳县| 昂仁县| 乌恰县| 肇庆市|