第一个springboot_web项目

依赖:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

静态资源

静态资源存放位置:1. webjars/ 下  访问时:localhost:8868/webjars/静态资源文件全路径
静态资源存放位置:2. 全局资源目录resources/下的 static/  public/ resources/ 或  /**(指直接在此全局资源路径里即全局资源目录resources\下)
  • 优先级: public/ < static/(默认) < resources/ 访问时:localhost:8868/资源文件名

    resources/public/ 一般:存放公共资源和页面
    resources/static/ 一般:存放静态资源和一个首页面
    resources/resources/
    resources/templates/ 一般:用于存放无法被用户直接访问到,只能通过Controller控制器跳转到的html页面


可只提交对象的一个属性

html:

<input name="department.id"><!--对象.属性-->
</input>

首页设置: 在 resources/public/ 或 resources/static/ 或 resources/resources/ 或resources/templates 目录下创建 index.html 即可替换首页面

springboot配置404,500…页面

在templates文件夹下,创建error文件夹,在error文件夹下创建404.html ,500.html..

/** 有多个同名springboot配置:application.yaml 生效优先级

  # 项目路径springboot_2_web/config/下       优先级:1
  # 项目路径springboot_2_web/下              优先级:2
  # 全局资源路径resources/config/下           优先级:3
  # 全局资源路径resources/下                 优先级:4 (默认,此优先级最低,将被其他优先级覆盖)

thymeleaf模板引擎:

在html文件头部引入:xmlns:th="http://www.thymeleaf.org"

基本使用: th:事件名="${属性/逻辑..}" 事件例如: text each....

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值