-
在
Application
類上加@MapperScan("org.mybatis.jpetstore.persistence")
-
將原有的jsp文件後綴改爲html
-
sessionScope
改session
-
給每個
Mapper
加@Mapper
-
在
application.properties
中加
mybatis.mapper-locations=classpath:/persistence/*.xml
mybatis.configLocation=classpath:/mybatis-config.xml
- 配置h2
# h2
spring.datasource.url =jdbc:h2:mem:mybatis_jpetstore_ssm
spring.datasource.driverClassName = org.h2.Driver
spring.datasource.schema=classpath:/database/jpetstore-hsqldb-schema.sql
spring.datasource.data=classpath:/database/jpetstore-hsqldb-dataload.sql
- 每個頁面需要加
<div id="Content"></div>
包裹
常用代碼
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<div th:include="@{common/IncludeTop}"></div>
<div th:include="@{/common/IncludeBottom}"></div>
<div id="BackLink"><a
th:href="@{/actions/Catalog.action}">
Return to Main Menu</a></div>
<span th:text="${#dates.format(order.orderDate,'yyyy/MM/dd hh:mm:ss')}"></span>
$<span th:text="${#numbers.formatDecimal(cartItem.item.listPrice,2,2)}"></span>
<div id="Content">