日期:2014-05-18 浏览次数:20923 次
@SuppressWarnings("serial")
@Controller("ConditionQueryAction")
// 指定该类的对象在spring容器中的作用域为prototype
@Scope("prototype")
@Transactional
public class ConditionQueryAction extends ActionSupport implements ModelDriven<Client>{
@Resource
private ClientDao clientdao;
private Client client;
private Pager pager;
private int page;
public Client getModel() {
if(client == null){
client=new Client();
}
return client;
}
//不定条件查询 将返回的pagers对象 传送到页面
public String execute(){
System.out.println("page1是======="+page);//这里有问题 每次不管点击下一页 还是最后一页 总是显示 page1是======= 0 !!
if(page==0)
page=1;
pager = clientdao.query(getModel(),page,5);
ActionContext.getContext().put("pager", pager);
ActionContext.getContext().put("models", getModel());
return SUCCESS;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
}
<form action="querys" method="post" name="theform">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="trTitle">单位名称:</td>
<td><label for="textfield"></label>
<input type="text" name="clientName" id="textfield" value="${models.clientName}"/></td>
<td> </td>
<td class="trTitle">客户编号:</td>
<td><input type="text" name="clientId" id="textfield5" /></td>
<td> </td>
<td class="trTitle">电 话:</td>
<td><label for="textfield2"></label>
<input type="text" name="telphone" id="textfield2" /></td>
</tr>
<tr>
<td class="trTitle">客户分类:</td>
<td><label for="select"></label>
<select name="clientType" id="select">
<option value="0">托运客户</option>
<option value="1">收货客户</option>
</select></td>
<td> </td>
<td class="trTitl