• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Origin Filter

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The SpringBoot Application

fronter access: error: 401

bakcend java filter is underthere

when I set a breakpoint, not entry the filter class.  The following Filter is not work.
but I use @Component annotation.  

why,  help

 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, @Component doesn't work for servlets or filters. If I recall correctly @WebServlet and @WebFilter should work instead. If you want some more fine-grained control, you can create an @Configuration class (or use an existing one) that has methods annotated with @Bean that return ServletRegistrationBean for servlets and FilterRegistrationBean for filters. These methods support proper auto-wiring of any arguments which you can pass to your servlets and filters if needed.

Also, are you aware that Spring Boot comes with CORS support out-of-the-box? Check out https://www.baeldung.com/spring-cors and https://spring.io/guides/gs/rest-service-cors/ for more information.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic