1、创建新的工程
package com.hengqin.springbootwebdemo.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class HelloController { @ResponseBody @RequestMapping("/hello") public String hello(){ return "Helloworld"; } }
2、SpringBoot对静态资源的映射规则;
1)、所有 /webjars/** ,都去 classpath:/META-INF/resources/webjars/ 找资源;
webjars:以jar包的方式引入静态资源
重新运行,访问:localhost:8080/webjars/jquery/3.5.1/jquery.js
在访问的时候只需要写webjars下面资源的名称即可
2)、"/**" 访问当前项目的任何资源,都去(静态资源的文件夹)找映射
localhost:8080/abc === 去静态资源文件夹里面找abc
3)、欢迎页; 静态资源文件夹下的所有index.html页面;被"/**"映射;
localhost:8080/ 找index页面
4)、所有的 **/favicon.ico 都是在静态资源文件下找;