How does springboot give priority to static resource url???

my static resource / css/style.css is accessed normally.
when I create a controller path is

@ResponseBody
    @GetMapping("/css/style.css")
    public String style() {
        return "fuck you";
}
The

result executes the path of the controller, outputting the string fuck you

I want to give priority to static resources, how to configure them? Now the priority controller is overwritten as long as the controller"s url overlaps with the static url.
I want to give priority to css. Static resources no longer exist to access the controller

May.04,2022

write a configuration class, inherit WebMvcConfigurerAdapter, rewrite its addResourceHandlers, and configure your static resource path in this method

Menu