7.Springboot之web开发

要解决的问题:

1.导入静态资源(html之类的(webapp))

2.首页

3.没有写Jsp的地方-------->所以要学模板引擎Thymeleaf

4.装配扩展springmvc

5.增删改查

6.拦截器

7.国际化(中英文切换)

1.静态资源

 页面放下面这几个包里,localhost:8080能直接访问到,/**是当前目录下

Publicresources是我们自己建的

2.首页如何定制

我习惯在public这个包里建

名字叫index.html

 这样就能直接在8080访问了

模板引擎

现在我们演示一下springboot里面怎么跳转页面

templates目录里面的页面只能通过@controller@RequestMapper(/pig)进行页面跳转进行访问且需要模板引擎的支持

下次创建项目的时候记得把这个给勾选上Thymeleaf

 

引入thymeleaf依赖

<!--引入thymeleaf依赖-->

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-thymeleaf</artifactId>

        </dependency>

 

因为要跳转嘛,跳转到别的页面的东西要在controller层里面写

 这里我们可以看到,所跳转的页面为test.html

 模板引擎还有获取值的功能

现在我们试着用模板引擎去获取值

 test.html

猜你喜欢

转载自www.cnblogs.com/tuyaojiao/p/12373338.html