where標簽用於簡化sql的書寫,if標簽用於判斷。大概的使用如下
<select id="getCountByPageInfo" parameterType="com.dabai.mytwo.entity.PageInfo"> select count(*) from forum <where> <if test="institutionid!=null"> institution_id=#{institutionid} </if> <if test="userid!=null"> and author_id=#{userid} </if> </where> </select>
其中pageInfo類如下
public class PageInfo implements Serializable {
private static final long serialVersionUID = 1L;
private Integer totalcount;
private Integer currentpage;
private Integer totalpage;
private Integer pagesize;
private Long institutionid;
private Long forumid;
private String userid;
private String ids;
private String code;
//get set方法
}