Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Origin Filter

Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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

Posts: 22018
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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 and for more information.
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic