做了一个页面查询:<th colspan="4">
图书名称
<s:textfield name="bookname" id="bookname" />
图书编号
<s:textfield name="bookno" id="bookno" />
<input name="searchbtn" type="image" src="../../images/search.gif"
width="63" height="22" border="0" /> 点击查询后 bookname bookno 都为空。。public String findBookMessage() {
Map map = new HashMap();
map.put("bookno", bookno);
map.put("bookname", bookname);try {
pagination = bookmgr.findbookmessage(map, pageNo, pageSize);
}
catch (Exception e) {
e.printStackTrace();
}
return LIST;
}
为什么sbookname 取不到值?该怎么改呢。。
图书名称
<s:textfield name="bookname" id="bookname" />
图书编号
<s:textfield name="bookno" id="bookno" />
<input name="searchbtn" type="image" src="../../images/search.gif"
width="63" height="22" border="0" /> 点击查询后 bookname bookno 都为空。。public String findBookMessage() {
Map map = new HashMap();
map.put("bookno", bookno);
map.put("bookname", bookname);try {
pagination = bookmgr.findbookmessage(map, pageNo, pageSize);
}
catch (Exception e) {
e.printStackTrace();
}
return LIST;
}
为什么sbookname 取不到值?该怎么改呢。。
第一个:action中有没有 bookname bookno 的get set方法
第二个:点击查询按钮的时候有没有放到form表单中,然后按钮的type值应该是submit类型的
还有你查询一下数据库中是否有对应的数据。
1、你說的查不到,是
图书名称
<s:textfield name="bookname" id="bookname" />
图书编号
<s:textfield name="bookno" id="bookno" />
這兩個在頁面刷新後沒有保留住查詢條件呢,還是查詢條件傳達到後台,後台沒有拿到?
2、畫面是否有表單域?
3、另外,你的map既然是作為封裝查詢結果的,它放在什麽範圍內?
页面内有表单域。。刷新后 表单域不变 页面刷新后没有 查询条件没有被传到后台。。
map的范围 应该没什么问题
//此处是否bookno和bookname没有值?
//如果没有值,你把你怎么定义的bookno和bookname代码给出来呗。
//你有写get和set方法吗?
map.put("bookno", bookno);
map.put("bookname", bookname);
private Integer bookno; // 图书编号
/**
* 图书管理首页
*
* @throw SQLException
*
*/
public String findBookMessage() {
Map map = new HashMap();
map.put("bookno", bookno);
map.put("bookname", bookname); try {
pagination = bookmgr.findbookmessage(map, pageNo, pageSize);
} catch (Exception e) {
e.printStackTrace();
}
return LIST;
}
public String getBookname()
{
return bookname;
}
public void setBookname(String bookname)
{
this.bookname=bookname;
}
public Integer getBookno()
{
return bookno;
}
public void setBookno(Integer bookno)
{
this.bookno=bookno;
}
Map map = new HashMap();
System.out.println("bookno:"+bookno);
map.put("bookno", bookno);
System.out.println("bookno:"+bookname);
map.put("bookname", bookname);
这两个地方打印都没有值吗?
id="mainForm">
<table width="100%" class="pickme" id="striped"
caption="Top Grossing Movies">
<tr bgcolor="#FFFFFF"> <th colspan="4">
图书名称
<s:textfield name="bookname" id="bookname" />
图书编号
<s:textfield name="bookno" id="bookno" />
<input name="searchbtn" type="image" src="../../images/search.gif"
width="63" height="22" border="0" />
</th>
</tr> </table>
<table width="100%" class="pickme" id="striped2"
caption="Top Grossing Movies">
<thead> <tr>
<th width="2%">
<input type=checkbox id="selectAll" style="cursor: hand;"></th>
<th width="16%">
书名
</th>
<th width="14%">
图书编号
</th>
<th width="14%">
作者
</th>
<th width="15%">
出版社
</th>
<th width="15%">
存放位置
</th>
<th width="13%">
借阅状态
</th>
<th width="15%">
基本操作
</th>
</tr>
</thead>
<tbody>
<s:iterator value="pagination.list" status="it">
<tr>
<td>
<input type="checkbox" name="ids"
value='<s:property value="id" />' disable="false" />
</td>
<td>
<s:property value="bookname" />
</td> <td>
<s:property value="bookno" />
</td>
<td>
<s:property value="author" />
</td>
<td>
<s:property value="pubhouse" />
</td>
<td>
<s:property value="area" />
</td>
<td>
<s:property value="lend" />
</td>
<td>
<a href="javascript:goEdit(<s:property value='id'/>)"> 编辑</a>
<a href="javascript:gotoDel(<s:property value='id'/>)">删除</a>
</td>
</tr>
</s:iterator>
</tbody>
</table>
<table width="100%" class="pickme" id="striped3"
caption="Top Grossing Movies">
<tr bgcolor="#FFFFFF">
<th colspan="2"></th>
</tr>
</table>
<div style="width: 100%; height: 25px;">
<%@ include file="/common/pages.jsp"%>
</div> </s:form>
登录时不报错 。。 查询 时 页面就报错 页面出来 但是查不到值