最近,做了一个保单查询。条件分页的时候,查询条件是保存在session中的。是把struts的FormBean保存在session中实现的。配制如下:
<action name="searchShipApplyForm" path="/searchShipApply" scope="session">
这样的话,分页条件就保存下来了。
但是,遇到第二次查询的时候,发现之前查询的条件居然还存在,本次提交的查询投保单号 空,但是之后查询的条件里面出现了前次的投保单号xxxxxx。
于是,在查询页面把session里面的条件需要清空。
if (session.getAttribute("policyMApplyForm") != null)
session.removeAttribute("policyMApplyForm");
if (session.getAttribute("searchShipApplyForm") != null) {
session.removeAttribute("searchShipApplyForm");
}
这样,查询就好了。以后再遇到这种分页 查询条件保存的时候,需要注意这种情况了。
之前也有遇到分页条件保存的问题,大多时候,我是通过URL参数的形式保存。
这样适合条件比较少的情况。
保单查询条件很多,保存在session中比较方便。但是需要注意及时清空。