ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
Please Subscribe and Support me
Good One!
Wah! Can't thank you enough, man. Thanks a ton! Keep going.
what if I it log only [Message filter] whenenver I enter the /customer route and log only [Product filter] whenever enter the route /product?
@Slf4j@Order(1) // Ensure this filter executes before MessageFilterpublic class ProductFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String requestURI = httpServletRequest.getRequestURI(); if ("/customer".equals(requestURI)) { chain.doFilter(request, response); return; // Skip the rest of the filter } log.info("[ProductFilter] - Inside doFilter method"); log.info("Local Port : " + request.getLocalPort()); log.info("Server Name : " + request.getServerName()); log.info("Method Name : " + httpServletRequest.getMethod()); log.info("Request URI : " + requestURI); log.info("Servlet Path : " + httpServletRequest.getServletPath()); chain.doFilter(request, response); }}Add condition before performing chain.doFilter
at 21:15 why does it log the same info twice?
Please Subscribe and Support me
Good One!
Wah! Can't thank you enough, man. Thanks a ton! Keep going.
what if I it log only [Message filter] whenenver I enter the /customer route and log only [Product filter] whenever enter the route /product?
@Slf4j
@Order(1) // Ensure this filter executes before MessageFilter
public class ProductFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
String requestURI = httpServletRequest.getRequestURI();
if ("/customer".equals(requestURI)) {
chain.doFilter(request, response);
return; // Skip the rest of the filter
}
log.info("[ProductFilter] - Inside doFilter method");
log.info("Local Port : " + request.getLocalPort());
log.info("Server Name : " + request.getServerName());
log.info("Method Name : " + httpServletRequest.getMethod());
log.info("Request URI : " + requestURI);
log.info("Servlet Path : " + httpServletRequest.getServletPath());
chain.doFilter(request, response);
}
}
Add condition before performing chain.doFilter
at 21:15 why does it log the same info twice?