Win a copy of Python Continuous Integration and Delivery this week in the Python 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Origin Filter  RSS feed

 
Ranch Hand
Posts: 42
  • 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

 
Sheriff
Posts: 21638
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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 https://www.baeldung.com/spring-cors and https://spring.io/guides/gs/rest-service-cors/ for more information.
 
Water proof donuts! Eat them while reading this tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!