文章目錄
- 一、圖檔浏覽
- 二、bookMapper.xml檔案代碼
一、圖檔浏覽
二、bookMapper.xml檔案代碼
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- mapper标簽下的路徑是dao層的路徑,因為dao層原本是用于書寫SQL語句的 -->
<mapper namespace="com.demo.ssm.dao.BookDao">
<select id="search" resultType="book">
select * from book
<where>
<if test="bookName != null and bookName != '' ">
and bname = #{bookName}
</if>
<if test="bookAuthor != null and bookAuthor != '' ">
and author = #{bookAuthor}
</if>
<if test="lowPrice != null and lowPrice != '' ">
and price >= #{lowPrice}
</if>
<if test="highPrice != null and highPrice != '' ">
and price <= #{highPrice}
</if>
</where>
</select>
</mapper>