Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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: 21558
100
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.
 
You don't like waffles? Well, do you like this tiny ad?
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!