Action层
@RequestMapping(value = "/adback/adManager.do")
public String page(Model model, HttpServletRequest request, Integer currPage) {
PageModel page = new PageModel();
page.setPageNumber(10);
if (currPage != null) {
page.setCurrentNumber(currPage);
}
Map<String, Object> param = new HashMap<String, Object>();
param.put("adState", request.getParameter("adState"));
if (StringUtil.isEntity(request.getParameter("siteName"))) {
param.put("siteName", request.getParameter("siteName"));
}
if (StringUtil.isEntity(request.getParameter("adClient"))) {
param.put("adClient", request.getParameter("adClient"));
}
if (StringUtil.isEntity(request.getParameter("adSite"))) {
param.put("adSite", request.getParameter("adSite"));
}
page = adService.queryPage(param, page);
model.addAttribute("page", page);
model.addAttribute("param", param);
model.addAttribute("requestUrl", "adManager.do");
return "/adback/adManager";
}
实现层
@Override
public PageModel queryPage(Map<String, Object> param, PageModel page) {
param.put("limitStart", page.getLimitStart());
param.put("limitEnd", page.getLimitEnd());
List<Map<String,Object>> result = myAdMapper.queryAd(param);
int count = myAdMapper.queryAdCount(param);
page.setResult(result);
page.setCountNumber(count);
return page;
}
[/size][size=x-small][size=small][/size]
持久层
List<Map<String, Object>> queryAd(Map<String, Object> param);
Integer queryAdCount(Map<String, Object> param);
<select id="queryAdCount" parameterType="map" resultType="java.lang.Integer" >
select count(*) as totalcount
from ad_point a, ad b where b.point_id=a.id
<if test="siteName != null">
and a.site_name=#{siteName}
</if>
<if test="adClient != null">
and b.ad_client like concat('%',#{adClient},'%')
</if>
<if test="adSite != null">
and a.site_remark like concat('%',#{adSite},'%')
</if>
<if test="adState != null and adState != 0" >
and b.state=#{adState}
转载于:https://blog.51cto.com/ajiao13/1135167