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 and so forth. 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 to 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 ...

Get Spring Boot Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.