Changing default URL mapping for Serving Static Content in Spring Boot

后端 未结 5 1679
鱼传尺愫
鱼传尺愫 2021-01-19 13:29

My static resources stopped working as soon as I added a new Controller (non rest) in my application with the following mapping

@RequestMapping(value = \"/{p         


        
5条回答
  •  不知归路
    2021-01-19 14:15

    Sure thing. There is a spring.mvc.static-path-pattern that you can use to override that:

    spring.mvc.static-path-pattern=/resources/**
    

    will map classpath:/static/css/foo.css to /resources/css/foo.css.

    (I've made that clearer in a862b6d)

    Having said that, I could only strongly recommend to change your path there. Having a path variable that catches the root context is really a bad idea.

提交回复
热议问题