文本框提交上来的action:
else if(dataUpdateType.equals("dataUpdateQueryButton"))
{
HttpSession session = request.getSession();
session.setAttribute("brandNumberSelect", brandNumberSelect) ;
session.setAttribute("brandNumberInput", brandNumberInput) ;
session.setAttribute("brandNumberKind", brandNumberKind) ;
}
return mapping.findForward("DataUpdateTurn");
首先判断是点击的是要查询的按钮,然后进到if体里,把从form里取出来的值分别保存给session,然后转到分页的action:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
HttpSession session = request.getSession();
String brandNumberSelect = (String)session.getAttribute("brandNumberSelect") ;
String brandNumberInput = (String)session.getAttribute("brandNumberInput") ;
String brandNumberKind = (String)session.getAttribute("brandNumberKind") ;
if(action==null||action.equals("null"))
{
list=new DateUpdateSelectListPageBean().findAll(brandNumberSelect,brandNumberInput,brandNumberKind);
}
在分页action里把session值取出来,然后把session以方法带参数的方式把值给SQL语句所在的方法,也就是下边的业务bean:
public List findAll(String brandNumberSelect,String brandNumberInput,String brandNumberKind)
{
List list = new ArrayList();
ResultSet rs = null;
final String SQL = "select hphm,hpzl,syr,wfsj,wfdd,wfdm,xh from dzjc_flow where fbbj='1' and clbj='0' and hphm = '"+brandNumberSelect+brandNumberInput+"' and hpzl = '"+brandNumberKind+"' " ;
System.out.println("DateUpdateSelectListPageBeanSQLL"+SQL);
try
{
rs = PageDBConnection.getResultSet(SQL);
while (rs.next())
{
DateUpdateSelectVo dateUpdateSelectVo = new DateUpdateSelectVo();
//这个顺序控制分页jsp显示的顺序
dateUpdateSelectVo.setHphm(rs.getString(1));
dateUpdateSelectVo.setHpzl(rs.getString(2));
dateUpdateSelectVo.setSyr(rs.getString(3));
dateUpdateSelectVo.setWfsj(rs.getString(4));
dateUpdateSelectVo.setWfdd(rs.getString(5));
dateUpdateSelectVo.setWfdm(rs.getString(6));
dateUpdateSelectVo.setXh(rs.getString(7));
list.add(dateUpdateSelectVo);
}
}
这样SQL语句就得到了文本框输入的值了,这样再用jsp里的.do开始执行分业的功能,到了查询数据库的时候就会按照文本框输入的值来查询了
黑色头发 http://heisetoufa.iteye.com