實訓: jpetstore改ssm版本

  • Application類上加@MapperScan("org.mybatis.jpetstore.persistence")

  • 將原有的jsp文件後綴改爲html

  • sessionScopesession

  • 給每個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">
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章