action中拿不到页面发来的参数!解决方法
action中拿不到页面发来的参数!
ACTION类
jsp
分页
ACTION类
@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;
}
}
jsp
<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="trTitle">联系人姓名</td>
<td><input type="text" name="linkmanName" id="textfield6" /></td>
<td> </td>
<td class="trTitle">简 拼:</td>
<td><input type="text" name="spellBJDX" id="textfield4" /></td>
</tr>
</table>
<input type="submit" name="button" id="button" value="查询" class="btn" />
<input type="reset" name="button2" id="button2" value="重置" class="btn"/>
</form>
分页
<td colspan="8" align="right">
<div >
总条记录${pager.rowCount} 每页${pager.pageSize}条 当前第${pager.page}/${pager.pageCount}页
<c:choose>
<c:when test="${ pager.first }">首页 | 上一页 | </c:when>
<c:otherwise><a href='' onclick="gotos(1)">首页</a> | <a href="" onclick="gotos(${pager.page - 1 }")>上一页</a> | </c:otherwise>
</c:choose>