O'Reilly logo

Spring MVC Beginner’s Guide by Amuthan G

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – adding the data audit interceptor

Using a simple MVC interceptor, you can accomplish audit logging without making changes to your application code. Create an interceptor to record an audit log using the following steps:

  1. Create a class called AuditingInterceptor under the package com.packt.webstore.interceptor in the source folder src/main/java and add the following code into it:
    package com.packt.webstore.interceptor; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; public class AuditingInterceptor ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required