jsp部分代码
<body>
<div id="a">
<table width="830" height="100" border="1" align="center">
<s:form method="post" action="show">
<tr>
<s:submit value="点击查询"></s:submit>
</tr>
<tr>
<td width="128" height="25" align="center"> 书号ID</td>
<td width="157" align="center">书名</td>
<td width="147" align="center">作者</td>
<td width="281" align="center">出版社</td>
</tr>
<s:iterator value="#request.list"id="show">
<tr>
<td><s:property value="#show.Id"/></td>
<td><s:property value="#show.bookName"/></td>
<td><s:property value="#show.writer"/></td>
<td><s:property value="#show.publisher"/></td>
</tr>
</s:iterator>
</s:form>
</table>
</div>
</body>
<body>
<div id="a">
<table width="830" height="100" border="1" align="center">
<s:form method="post" action="show">
<tr>
<s:submit value="点击查询"></s:submit>
</tr>
<tr>
<td width="128" height="25" align="center"> 书号ID</td>
<td width="157" align="center">书名</td>
<td width="147" align="center">作者</td>
<td width="281" align="center">出版社</td>
</tr>
<s:iterator value="#request.list"id="show">
<tr>
<td><s:property value="#show.Id"/></td>
<td><s:property value="#show.bookName"/></td>
<td><s:property value="#show.writer"/></td>
<td><s:property value="#show.publisher"/></td>
</tr>
</s:iterator>
</s:form>
</table>
</div>
</body>
解决方案 »
- 使用了Spring,在一个service里使用了2个DAO ,如何配置spring?
- 内存分析重不重要
- google浏览器的问题
- 新手发问:关于一对多的实现问题,请大家帮助!!!
- 你们管理员都是干什么的?
- Hibernage为什么不能自动创建数据库
- 如何改变field级别的错误信息的颜色显示
- 关于light portal
- 使用了Struts2 的Annotation技术之后报的错,怎么解决,谢谢
- 我安装了J2EE1.4SDK 在哪写程序啊,怎么启动命令编译调试啊
- EJB访问数据库出错
- 【求助】Struts2 Annotation java.lang.reflect.InvocationTargetException
我的ShowAction.java代码
package org.action;import java.util.List;
import java.util.Map;
import org.model.Show;
import org.dao.ShowDao;import com.opensymphony.xwork2.ActionContext;
public class ShowAction{
private List<Show> list;
public List<Show> getList() {
return list;
} public void setList(List<Show> list) {
this.list = list;
}
private Show show;
public Show getShow() {
return show;
} public void setShow(Show show) {
this.show = show;
}
public String execute() throws Exception{
ShowDao showDao=new ShowDao();
List list=showDao.selectShow(show.getId(),show.getBookName(),show.getWriter(),show.getPublisher());
Map request=(Map) ActionContext.getContext().get("request");
request.put("list", list);
return SUCCESS;
}
}
import org.db.DBConn;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.model.Show;public class ShowDao {
Connection conn;
public List<Show> selectShow(int Id,String bookName,String writer,String publisher){
List<Show> list=new ArrayList<Show>();
conn=DBConn.getConn();
try{
PreparedStatement pstmt=conn.prepareStatement("select * from book order by Id");
ResultSet rs=pstmt.executeQuery();
while(rs.next()){
Show show=new Show();
show.setId(rs.getInt(1));
show.setBookName(rs.getString(2));
show.setWriter(rs.getString(3));
show.setPublisher(rs.getString(4));
list.add(show);
}
return list;
}catch(Exception e){
e.printStackTrace();
return null;
}finally{
DBConn.CloseConn();
} }
}
还有model的set,get方法