springboot configures the Filter path through @WebFilter(urlPatterns ), without configuring /*, you can enter the filter by entering any path

@Slf4j
@Component
@ServletComponentScan
@WebFilter(urlPatterns = {"/config/*","/driver/*","/order/*","/im/*","/privacy/*","/config/*"}, filterName = "apiFilter")
public class SecurityRequestFilter implements Filter {
}

In the above code, urlPatterns does not specify the "/" root path to be filtered, but after entering http://localhost:8080/, it can enter the filter.

Start printing log as follows:

 Observing the log, we can see that in addition to displaying the registered filters using filterName = "apiFilter", they also try to register a filter with the first letter of the class name as lowercase (securityRequestFilter).

 

Solution: The filterName = "apiFilter"  modify filterName = "securityRequestFilter", overwrite the hidden register test filter, thus avoiding a plurality of registered filters. So as to solve the problem that any path input can enter the filter.

Guess you like

Origin blog.csdn.net/huangpeigui/article/details/89513769