MyBatis Essential Patterns and Best Practices
Insert Operations
Retrieving Auto-Generated Primary Keys
<insert id="saveCustomer" useGeneratedKeys="true" keyProperty="customerId"
parameterType="com.example.domain.Customer">
INSERT INTO customer(name, points, created_at)
VALUES (#{name}, #{points}, #{createdAt})
</insert>
Batch ...
Posted on Mon, 21 Sep 2026 16:18:09 +0000 by desmortes
Disabling Swagger UI in Spring Boot to Prevent Vulnerability Scanning
When deploying Spring Boot applications to production, it’s essential to completely disable the Swagger UI to avoid exposing API documentation and to pass automated security scans. This article outlines a practical approach to turn off Swagger, including hiding any residual Swagger‑related endpoints.
Step 1: Disable the Swagger Docket bean via ...
Posted on Thu, 17 Sep 2026 16:38:39 +0000 by garry
Implementing Custom Interceptors in Spring MVC
Define a custom interceptor in bean configuration file
<mvc:interceptors>
<!-- Custom interceptor declaration -->
<bean class="com.example.interceptors.CustomInterceptor"/>
</mvc:interceptors>
Implementation of the interceptor class
package com.example.interceptors;
import javax.servlet.http.HttpServl ...
Posted on Sat, 29 Aug 2026 16:53:44 +0000 by Ironphp
Understanding and Using Struts2 Interceptors
Struts2 interceptors are a core mechanism for implementing cross-cutting concerns in web applications, leveraging aspect-oriented programming principles. Similar in concept to servlet filters, interceptors execute logic before and after an action method is invoked. However, unlike filters that operate at the servlet container level, Struts2 int ...
Posted on Fri, 14 Aug 2026 16:51:28 +0000 by mbeals
Configuring and Using Custom Interceptors in Spring MVC
Creating a Custom Interceptor by Extending HandlerInterceptorAdapter
Implementing the Interceptor Class
Create a new class that extends HandlerInterceptorAdapter and annotate it with @Component:
package com.example.interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org. ...
Posted on Thu, 13 Aug 2026 16:26:13 +0000 by dubrubru
Implementing Request Encryption with RestClient Interceptors
When implementing request encryption that includes payload data, the conventional approach involves converting the request body to a string format before encryption. Here's a typical pattern:
String payloadString = ModelOptionsUtils.toJsonString(payload);
String hashedRequestPayload = sha256Hex(payloadString);
// Add hashedRequestPayload to hea ...
Posted on Wed, 12 Aug 2026 16:55:32 +0000 by kaitan
Extracting HTTP Request Parameters in Spring Boot Interceptors
Reading HTTP request parameters within a Spring Boot HandlerInterceptor presents a speicfic challenge: the servlet input stream can only be consumed once. If a downstream controller or another filter reads the body, the interceptor will encounter an empty stream. To resolve this, the request must be wrapped to cache the payload, allowing multip ...
Posted on Mon, 20 Jul 2026 16:39:11 +0000 by LiamH
Handling All Requests in Spring MVC with Filters and Interceptors
Spring MVC provides two primary mechanisms for intercepting and processing all incoming requests: servlet filters and handler interceptors. Each serves distinct purposes and operates at different layers of the application.
1. Using a Servlet Filter
A servlet filter operates before request reaches the DispatcherServlet, allowing you to inspect ...
Posted on Sat, 18 Jul 2026 16:35:42 +0000 by qhiiyr
Implementing Soft Delete with MyBatis Interceptor
@Intercepts({
@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})
})
@Component
public class SoftDeleteInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
StatementHandler handler = (StatementHandler) in ...
Posted on Fri, 19 Jun 2026 16:59:07 +0000 by vornn
Implementing JWT Authentication in Spring Boot Applications
JSON Web Tokens consist of three distinct segments: a header defining cryptographic parameters, a payload carrying assertions, and a signature ensuring integrity. Implementing token validation in a Spring ecosystem requires orchestrating token generation, externalized configuration, request interception, and MVC registration. The following guid ...
Posted on Wed, 10 Jun 2026 18:12:59 +0000 by henryblake1979