[code="java"]<%@ page language="java" contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.List" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<%@ page import="java.util.LinkedList;" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
List list=(List)request.getAttribute("rsArray");
out.println(list);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>selectInfo.jsp</title>
</head>
修改
删除
部门 : | 使用人 : | 品牌: | |||||||||||||||
购机时间 : | 计算机名 : | 使用人 : |
/html:html
[/code]
action
[code="java"]public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SelectInfoForm selectInfoForm = (SelectInfoForm) form;// TODO
// Auto-generated
// method stub
String brand = (String)selectInfoForm.getBrand();
String buyTime = (String)selectInfoForm.getBuytime();
String departname = (String)selectInfoForm.getDepartname();
String owner = (String)selectInfoForm.getOwner();
String Pcname = (String)selectInfoForm.getPcname();
String username = (String)selectInfoForm.getUsername();
System.out.println(brand +"_____________"+buyTime+ "__________"+
departname+"________" +owner +"_____"+Pcname+"______________"+username);
StringBuffer clause = new StringBuffer("select * from infopc where 1=1 ");
if(!brand.equals("")){
clause.append("and brand='"+brand+"'");
}
if(!buyTime.equals("")){
clause.append("and buytime='"+buyTime+"'");
}
if(!departname.equals("")){
clause.append("and departname='"+departname+"'");
}
if(!owner.equals("")){
clause.append("and owner='"+owner+"'");
}
if(!Pcname.equals("")){
clause.append("and pcname='"+Pcname+"'");
}
if(!username.equals("")){
clause.append("and username='"+username+"'");
}
System.out.println("_______sql____________:" + clause);
DB db = null;
try {
db = new DB();
db.connDb();
ResultSet rs = db.executeQuery(clause.toString());
List list= new ArrayList();
while(rs.next()) {
//System.out.println("____ResultSet have value!___________");
//Integer.parseInt(arg0)
list.add(rs.getInt(1));
list.add(rs.getString(2));
list.add(rs.getString(3));
list.add(rs.getString(4));
list.add(rs.getString(5));
list.add(rs.getString(6));
list.add(rs.getString(7));
list.add(rs.getString(8));
list.add(rs.getString(9));
list.add(rs.getString(10));
list.add(rs.getString(11));
list.add(rs.getString(12));
list.add(rs.getString(13));
list.add(rs.getString(14));
list.add(rs.getString(15));
list.add(rs.getString(16));
list.add(rs.getString(17));
list.add(rs.getString(18));
list.add(rs.getString(19));
System.out.println("rs.getInt(1):"+rs.getInt(1));
System.out.println("list.size() :"+list.size());
System.out.println(rs.getInt(1)+rs.getString(2));
}
request.setAttribute("rsArray", list);
System.out.println("session_______setAttribute得值是:"+list);
System.out.println("____can run here!!!____________");
return mapping.findForward("success");
} catch (Exception e) {
} finally {
if (db != null)
db.closeDb();
}
return null;
}[/code]
解决了一个下午 有点迷糊了
[b]问题补充:[/b]
写了个类 com.xxx.struts.util.Pcinfo 得到新异常。。
javax.servlet.ServletException: Cannot find bean Pcinfo in any scope
while(rs.next()) {
//System.out.println("____ResultSet have value!___________");
//Integer.parseInt(arg0)
list.add(rs.getInt(1));
list.add(rs.getString(2));//depart
list.add(rs.getString(3));//owner
list.add(rs.getString(4));//pcname
list.add(rs.getString(5));//username
list.add(rs.getString(6));//post
list.add(rs.getString(7));//brand
list.add(rs.getString(8));//type
list.add(rs.getString(9));//cpu
list.add(rs.getString(10));//mem
list.add(rs.getString(11));//disksum
list.add(rs.getString(12));//ram
list.add(rs.getString(13));//iscrty
list.add(rs.getString(14));//buytime
list.add(rs.getString(15));//tele
list.add(rs.getString(16));//spec
list.add(rs.getString(17));//usething
list.add(rs.getString(18));//virus
list.add(rs.getString(19));//remark
Pcinfo ipform= new Pcinfo();
ipform.setBrand(rs.getString(7));
ipform.setBuytime(rs.getString(14));
ipform.setCpu(rs.getString(9));
ipform.setDepartname(rs.getString(2));
ipform.setDisksum(rs.getString(11));
ipform.setIscrystal(rs.getString(13));
ipform.setMemory(rs.getString(10));
ipform.setOwner(rs.getString(3));
ipform.setPcname(rs.getString(4));
ipform.setPost(rs.getString(6));
ipform.setRam(rs.getString(12));
ipform.setRemark(rs.getString(19));
ipform.setSpecsoft(rs.getString(16));
ipform.setTele(rs.getString(15));
ipform.setType(rs.getString(8));
ipform.setUsername(rs.getString(5));
ipform.setUsething(rs.getString(17));
ipform.setVirus(rs.getString(18));
list.add(ipform);
界面 如下:
/logic:iterate
/logic:present.
写法不对?