springboot2

1、controller的使用:请求及映射路径部分注解

@Controller:处理http请求

@RequestMapping配置url配置

@ResponseBody:方法返回格式为text/json

@RestController 返回Json数据

2、处理URL中的参数

@PathVariable:获取URL中的数据

@RequestParam:获取请求参数中的值

@GetMapping组合注解

3、springboot访问静态资源存入jar包,引入:从JAR目录结构的webjars开始写

4、自己写的静态资源:springboot的一些结构用来放入静态资源文件

"classpath: /META-INF/resources/"、"classpath: /resource/","classpath: /static/","classpath: /public/"

以上目录访问静态资源,访问后不需要加路径

5、欢迎页:静态资源目录的Index.html

自定义icon:favicon.ico放入任意静态资源文件中即可

6、动态资源:从程序或者数据库读取数据显示

7、网页:模板+数据

8、

 

 9、自动装配: ThymeleafAutoConfiguration      XXXXProperties

thymeleaf:默认路径:/templates/xx.html

10、使用Thymeleaf无法生效,注意检查:

(1)controller用@Controller类并且注意不要用@ResponseBody ,否则thmeleaf无法生效

(2)使用Thymeleaf导入以下依赖

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-spring5</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-java8time</artifactId>
        </dependency>

 

posted on 2020-09-10 16:56  ChanXM  阅读(158)  评论(0)    收藏  举报

导航