Lunigorn
Lunigorn

Reputation: 1422

How to disable static content handle in spring-boot?

I'm using this link to configure security and spring-boot as base for other. But static resource handler provided by spring-boot is executed before security settings. So if I send POST request, static content handler respond me that method POST not supported. If I request GET method, static response handler catch it and try to find resourse. So any requests catched by static content handler and not go to security filters.

How can I disable static content filters/handlers provided by spring-boot?

Upvotes: 11

Views: 19925

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116171

If you are using Spring Boot 2.4.0 or later, you can disable the static resource handling by setting spring.web.resources.add-mappings=false in your application.properties file. In earlier versions of Spring Boot, the property is spring.resources.add-mappings.

With that out of the way, are you sure that it will resolve your problem? Spring Security runs as a filter before the static resource handling and I doubt that disabling the resource handling will help. Perhaps it'll make it easier to identify the underlying problem, though.

Upvotes: 23

Related Questions