How do you implement input sanitization in Spring Boot?
Combine Bean Validation, parameterized queries, output encoding and allow-list HTML sanitizing to keep untrusted input from harming a Spring Boot application.
2,881 posts about Java: questions with answers, tutorials and articles, newest first.
Combine Bean Validation, parameterized queries, output encoding and allow-list HTML sanitizing to keep untrusted input from harming a Spring Boot application.
@Validated triggers Bean Validation with groups and enables method validation on beans. See how it differs from @Valid and which exceptions it raises.
Customize Bean Validation messages in Spring Boot with annotation attributes, messages.properties, locale files and a clean ProblemDetail error response.
Use spring-boot-starter-validation, Jakarta constraint annotations and @Valid to validate requests, then return structured 400 errors from one exception handler.
How the jjwt Claims interface exposes the exp claim, how the parser rejects expired tokens, and how to handle expiration in a Spring Boot filter.
Configure JWT expiry in Spring Boot with jjwt 0.12, handle ExpiredJwtException, issue rotating refresh tokens and test token expiry with a fixed Clock.
Configure session timeout and secure cookies in Spring Boot, share sessions across instances with Spring Session, or go stateless with tokens.
The spring-boot-starter-data-redis starter adds Spring Data Redis and the Lettuce client and auto-configures templates, caching and connections.
@Cacheable is a Spring annotation, and Redis is the store behind it. Learn how to configure RedisCacheManager, TTLs and serialisation in Spring Boot 3.
The propagation attribute decides whether a transactional method joins, suspends or avoids an existing transaction. See each level with examples and rollback behaviour.
Propagation.NESTED runs inside the outer transaction and rolls back to a savepoint on failure. Learn how to use it and why it sometimes seems to do nothing.
@Before, @After, and @Around are Spring AOP advice types that run code around method calls. Learn how they differ and when to choose each.
Learn to write Spring AOP pointcuts with @Pointcut, execution, within and @annotation, reuse them in advice, and avoid proxy pitfalls.
The @Aspect annotation declares a Spring AOP aspect. Learn how to enable it, write pointcuts and advice, and avoid self-invocation and proxy limits.
Add the AOP starter, create an @Aspect component and apply advice through a custom annotation. Covers auditing, security checks, pointcuts and testing.
@Slf4j is a Lombok annotation that generates an SLF4J logger in your class. Learn setup, usage with Spring Boot logging and common pitfalls.
Set up Actuator, Micrometer metrics, tracing and slow-query visibility to find and fix performance problems in a Spring Boot application.
Spring Boot has no built-in LoggingFilter class, but a servlet filter can log every request and response. See the built-in option and a custom filter.
Set up log rotation in Spring Boot using Logback rolling policy properties, a logback-spring.xml file or Log4j2, with size, history and compression.
Customise Spring Boot logging with properties and logback-spring.xml, including rolling files, profile-specific appenders, JSON output and runtime log levels.