- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 171字
- 2021-06-24 19:24:40
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.
- 輕松學(xué)大數(shù)據(jù)挖掘:算法、場景與數(shù)據(jù)產(chǎn)品
- MySQL從入門到精通(第3版)
- PySpark大數(shù)據(jù)分析與應(yīng)用
- Hadoop與大數(shù)據(jù)挖掘(第2版)
- 數(shù)據(jù)庫技術(shù)及應(yīng)用教程
- 新基建:數(shù)據(jù)中心創(chuàng)新之路
- 達(dá)夢數(shù)據(jù)庫運(yùn)維實(shí)戰(zhàn)
- 辦公應(yīng)用與計(jì)算思維案例教程
- 數(shù)據(jù)科學(xué)實(shí)戰(zhàn)指南
- 一本書講透Elasticsearch:原理、進(jìn)階與工程實(shí)踐
- Power BI智能數(shù)據(jù)分析與可視化從入門到精通
- 數(shù)據(jù)分析師養(yǎng)成寶典
- Hands-On System Programming with C++
- 數(shù)據(jù)分析思維:產(chǎn)品經(jīng)理的成長筆記
- Scratch 2.0 Game Development HOTSHOT