java - Spring Boot mapping filter to /* even when using @WebFilter with url pattern -
i defined filter in spring boot application (1.3.5) , annotated below
@webfilter(urlpatterns = {"/api/*"}, description = "create sessions api requests.") public class sessionfilter implements filter {
i want use filter create session records in database api requests. however, i'm seeing filter getting called /favicon.ico
request also. annotated main class @servletcomponentscan
well. classes under sub packages of main class.
from logs, see [/*]
being mapped filter. can't why.
[2016-06-09 22:39:34] [ info] [ost-startstop-1] [] [o.s.b.c.embedded.filterregistrationbean ][configure : 271] - mapping filter: 'com.mycompany.package.filter.sessionfilter' urls: [/api/*] [2016-06-09 22:39:34] [ info] [ost-startstop-1] [] [o.s.b.c.embedded.filterregistrationbean ][configure : 258] - mapping filter: 'sessionfilter' to: [/*]
i registered following enable servlet 3.0 api.
@configuration public class webconfigurer implements servletcontextinitializer {
i'm running in embedded tomcat.
update:
when added filtername
parameter mysessionfilter
, log looked below. had add @configuration
filter this.
[2016-06-14 18:55:58] [ info] [ost-startstop-1] [] [o.s.b.c.embedded.filterregistrationbean ][configure : 271] - mapping filter: 'mysessionfilter' urls: [/api/*] [2016-06-14 18:55:58] [ info] [ost-startstop-1] [] [o.s.b.c.embedded.filterregistrationbean ][configure : 258] - mapping filter: 'sessionfilter' to: [/*]
Comments
Post a Comment