79146494

Date: 2024-10-31 22:30:17
Score: 1
Natty:
Report link

When using @Component + @WebFilter, you're actually registering the filter twice with Embedded Tomcat:

This is why using both annotations works, but it's not the recommended approach

but in Traditional Spring MVC (External Tomcat):

When using external Tomcat, the servlet container handles @WebFilter registration directly This is why you get the "already registered" error when using both annotations

=> Working with Just @WebFilter require using @ServletComponentScan in the Spring Boot application, This annotation enables scanning for servlet components including @WebFilter

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @WebFilter
  • Starts with a question (0.5): When
  • Low reputation (0.5):
Posted by: Mohamed amine ben hassen