Springboot(四)——web开发

web开发

静态资源

四个目录存放的静态资源可以被我们识别,用来存放我们的html、css、js、图片等文件

"classpath:/META-INF/resources/"
"classpath:/resources/"
"classpath:/static/"
"classpath:/public/"

他们的优先级是:resources>static(默认)>public

可以在配置文件中制定静态资源路径

#制定静态资源路径
spring.mvc.static-path-pattern=/hello/,classpath:/study 

首页

springboot首页可以放到resources下,也可以放到resources/static或者resources/public都可以

一、在静态资源目录下新建index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>首页</h1>
</body>
</html>

二、编写controller层

@Controller
public class IndexController {

    @RequestMapping("/index")
    public String index(){
        return "index";
    }
}

三、运行测试

image

posted @ 2021-07-22 17:04  鬼谷仙生  阅读(33)  评论(0编辑  收藏  举报