1..添加父工程坐标并导入其他springboot不提供的jar包
2.访问静态资源
- classpath:/META-INF/resources/
- classpath:/resources/
- classpath:/static/
- classpath:/public
只要静态资源放在这些目录中任何一个,SpringMVC都会帮我们处理。
3.建立静态资源目录后将资源放入 //表示该目录下的资源加载不会进行拦截,作用等价于springmvc中的资源放行
4.编写application.yml文件,内容为druid配置, mybatis 扫描包,mapping映射 thymeleaf的缓存问题。//由于这里并未使用jsp,而是使用了thymeleaf模板
5.编写后台代码,并编写对应的html文件并将其标签头改为<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">以及引用进行对应修改 将其放入templates文件夹内
该网页不能直接进入,需要服务器内部跳转
//建立templates文件夹作为默认文件夹(boot框架默认其为绝对路径)
注意
前端thymeleaf页面改写 //主要看md文件 @${}一般在src即引用时使用该语法
thymeleaf的页面中 在js中获取存在作用域的值
将平常的表头加上一个属性th:inline="javascript"就可以了
<script type="text/javascript" th:inline="javascript">
dao层mapper接口要记得加上注解
mapper文件改写
例如
<association property="city" javaType="com.vp.pojo.City">
<id column="cityId" property="cityid"></id>
<result column="cityName" property="cityname"></result>
</association>