Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 792
Lunigorn Avatar asked Dec 16 '14 01:12

Lunigorn


People also ask

How do you serve a static html content page in spring boot?

Using Spring BootSpring Boot comes with a pre-configured implementation of ResourceHttpRequestHandler to facilitate serving static resources. By default, this handler serves static content from any of the /static, /public, /resources, and /META-INF/resources directories that are on the classpath.

How does Spring MVC handle static content?

Create a static file final. Update the Spring configuration file HelloWeb-servlet. xml under the WebContent/WEB-INF folder as shown below. The final step is to create the content of the source and configuration files and export the application, which is explained below.


1 Answers

You can disable the static resource handling by setting spring.resources.add-mappings=false in your application.properties.

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.

like image 126
Andy Wilkinson Avatar answered Sep 20 '22 12:09

Andy Wilkinson