这个有点麻烦!不过很简单。需要耐心看下去
先发一下我的javabean吧,如下:ZyForm.javapackage form;import java.sql.Blob;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;public class ZyForm {
private String ID; //ID
private String EXPLOSIVES_NAME; //炸药名称
private String MOLECULAR_FORMULA; //分子式
private String RELATIVE_MOLECULAR_WEIGHT; //相对分子质量
private String OXYGEN_BALANCE; //氧平衡
(这里省略了)
public String getID() {
return ID;
}
public void setID(String id) {
ID = id;
}
public String getExp() {
return EXPLOSIVES_NAME;
}
。(这部分省略了。)
}信息查询结果页面:
zyjgQuery.jsp<%@ page language="java" contentType="text/html; charset=GB2312"
pageEncoding="GB2312"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*"%>
<%@ page language="java" %>
<%@ include file="top.jsp" %>
<jsp:useBean id="zy" scope="page" class="form.ZyForm" scope="session"/><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>取得数据</title>
</head>
<body>
<CENTER><FONT size=5 color=blue><br>炸药信息查询结果
</FONT></CENTER>
<BR><HR><BR>
<%
//得到关键字
String keyword=request.getParameter("keyword");
keyword=new String(keyword.getBytes("ISO-8859-1"),"gbk");
%>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%">你所查询的关键词为:</td><td><%=keyword%></td>
<td><a href="zyQuery.jsp">返回</a></td>
</tr>
</table>
<%
//连接数据库
Connection con=null;
Statement stmt=null;
ResultSet rs=null; try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con =DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.8:1521:orcl", "scott", "tiger");
stmt =con.createStatement();
rs = stmt.executeQuery("select * from scott.danzhi where scott.danzhi.EXPLOSIVES_NAME like '%"+keyword+"%' ");
%>
<p>所查到的数据如下:</p>
<table bgcolor=DodgerBlue>
<tr bgcolor=SkyBlue>
<td width="14%" height="16" align="center">炸药名称</td>
<td width="10%" align="center">外观</td>
<td width="9%" align="center">爆热</td>
<td width="8%" align="center">装药密度</td>
<td width="7%" align="center">爆速<br></td>
<td width="10%" align="center">爆压<br></td>
<td width="9%" align="center">粘度</td>
<td width="10%" align="center">摩擦感度</td>
<td width="10%" align="center">撞击感度</td>
<td width="11%" align="center">详细参数</td>
</tr>
<%
List list=new ArrayList();
while (rs.next()){
%>
<tr>
<td bgcolor=LightYellow width="14%" height="16" align="center"><%=rs.getString("EXPLOSIVES_NAME")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("APPEARANCE")%></td>
<td bgcolor=LightYellow width="9%" align="center"><%=rs.getString("HOT_BLAST")%></td>
<td bgcolor=LightYellow width="8%" align="center"><%=rs.getString("CHARGE_DENSITY")%></td>
<td bgcolor=LightYellow width="7%" align="center"><%=rs.getString("DETONATION_VELOCITY")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("DETONATION_PRESSURE")%></td>
<td bgcolor=LightYellow width="9%" align="center"><%=rs.getString("VISCOSITY")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("FRICTION_SENSITIVITY")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("IMPACT_SENSITIVITY")%></td>
<td bgcolor=LightYellow width="11%" align="center"><a href="zyDetail.jsp"><center>查看</center></a></td></tr>
<%
zy.setDat(rs.getString("DATA_SOURCES"));
zy.setApl(rs.getString("APPLICATION"));
zy.setMot(rs.getString("MOTYPE_COEFFICIENT"));
zy.setEla(rs.getString("ELASTIC_MODULUS"));
。(这部分就不写了,大家应该知道什么意思吧!)list.add(zy);
session.setAttribute("ZyForm",list);
}}
catch (ClassNotFoundException e1) {e1.printStackTrace();}
catch (SQLException e2) {e2.printStackTrace();}
catch(NullPointerException e3) {e3.printStackTrace();}
try{
rs.close();
stmt.close();
con.close();
}
catch(NullPointerException e) {e.printStackTrace();}
%>
</table>
</body>
</html>
<%@ include file="bottom.jsp" %>单个数据详细信息页面(也就是上面页面的一个链接,黄色显示处):
zyDetail.jsp<%@ page language="java" import="java.sql.*" pageEncoding="gbk" errorPage="Error.jsp"%>
<%@ page language="java" %>
<%@ page import="java.util.*"%>
<jsp:useBean id="zy" scope="page" class="form.ZyForm" scope="session"/><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>详细信息</title>
</head>
<body><table width="103%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="photo/default_04.gif" width="768" height="31" /></td>
</tr>
</table>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><span class="STYLE18">炸药数据库</span></div></td>
</tr>
</table>
<%
List l=(List)session.getAttribute("ZyForm");
for(int i = 0; i < l.size(); i++)
{
ZyForm zy=(ZyForm)l.get(i);%>
<table width="100%" height="406" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="406"><table width="80%" height="782" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" height="29"><div align="right">炸药名称:</div></td>
<td width="16%"><%=zy.getExp(i)%></td>
<td width="22%">分子式:</td>
<td width="40%"><%=zy.getMol(i)%></td>
</tr>
<tr>
<td height="32"><div align="right">应用简况:</div></td>
<td colspan="3"><%=zy.getApl(i)%></td>
</tr>
<tr>
<td height="31"><div align="right">结构式:</div></td>
<td colspan="3"><%=zy.getStr(i)%></td>
</tr>
<tr>
<td height="24">炸药性能参数</td>
</tr>
<tr>
<td height="26"><div align="right">相对分子质量:</div></td>
<td><%=zy.getRel(i)%></td>
<td><div align="right">氧平衡:</div></td>
<td><%=zy.getOxy(i)%></td>
</tr>
<tr>
<td height="29"><div align="right">蒸汽压:</div></td>
<td><%=zy.getVap(i)%></td>
<td><div align="right">熔点:</div></td>
<td><%=zy.getMel(i)%></td>
</tr>
。(这部分省略了)
</table>
</td>
</tr>
</table>
<%
}
%>
</body>
</html>
出了点错误,错误在于zydetail.jsp网页红色代码处。错误如下:ZyForm cannot be resolved to a type。我不是建了ZyForm这个类吗?而且绿色的代码把它也加到网页上了。为什么还有这个错误?
大家有意见尽管说,我是初学者。Web工程这方面才学了几天。
从zyjgQuery.jsp转到zyDetail.jsp用以上方法不知道行不行。大家给点意见。
先发一下我的javabean吧,如下:ZyForm.javapackage form;import java.sql.Blob;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;public class ZyForm {
private String ID; //ID
private String EXPLOSIVES_NAME; //炸药名称
private String MOLECULAR_FORMULA; //分子式
private String RELATIVE_MOLECULAR_WEIGHT; //相对分子质量
private String OXYGEN_BALANCE; //氧平衡
(这里省略了)
public String getID() {
return ID;
}
public void setID(String id) {
ID = id;
}
public String getExp() {
return EXPLOSIVES_NAME;
}
。(这部分省略了。)
}信息查询结果页面:
zyjgQuery.jsp<%@ page language="java" contentType="text/html; charset=GB2312"
pageEncoding="GB2312"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*"%>
<%@ page language="java" %>
<%@ include file="top.jsp" %>
<jsp:useBean id="zy" scope="page" class="form.ZyForm" scope="session"/><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>取得数据</title>
</head>
<body>
<CENTER><FONT size=5 color=blue><br>炸药信息查询结果
</FONT></CENTER>
<BR><HR><BR>
<%
//得到关键字
String keyword=request.getParameter("keyword");
keyword=new String(keyword.getBytes("ISO-8859-1"),"gbk");
%>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%">你所查询的关键词为:</td><td><%=keyword%></td>
<td><a href="zyQuery.jsp">返回</a></td>
</tr>
</table>
<%
//连接数据库
Connection con=null;
Statement stmt=null;
ResultSet rs=null; try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con =DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.8:1521:orcl", "scott", "tiger");
stmt =con.createStatement();
rs = stmt.executeQuery("select * from scott.danzhi where scott.danzhi.EXPLOSIVES_NAME like '%"+keyword+"%' ");
%>
<p>所查到的数据如下:</p>
<table bgcolor=DodgerBlue>
<tr bgcolor=SkyBlue>
<td width="14%" height="16" align="center">炸药名称</td>
<td width="10%" align="center">外观</td>
<td width="9%" align="center">爆热</td>
<td width="8%" align="center">装药密度</td>
<td width="7%" align="center">爆速<br></td>
<td width="10%" align="center">爆压<br></td>
<td width="9%" align="center">粘度</td>
<td width="10%" align="center">摩擦感度</td>
<td width="10%" align="center">撞击感度</td>
<td width="11%" align="center">详细参数</td>
</tr>
<%
List list=new ArrayList();
while (rs.next()){
%>
<tr>
<td bgcolor=LightYellow width="14%" height="16" align="center"><%=rs.getString("EXPLOSIVES_NAME")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("APPEARANCE")%></td>
<td bgcolor=LightYellow width="9%" align="center"><%=rs.getString("HOT_BLAST")%></td>
<td bgcolor=LightYellow width="8%" align="center"><%=rs.getString("CHARGE_DENSITY")%></td>
<td bgcolor=LightYellow width="7%" align="center"><%=rs.getString("DETONATION_VELOCITY")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("DETONATION_PRESSURE")%></td>
<td bgcolor=LightYellow width="9%" align="center"><%=rs.getString("VISCOSITY")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("FRICTION_SENSITIVITY")%></td>
<td bgcolor=LightYellow width="10%" align="center"><%=rs.getString("IMPACT_SENSITIVITY")%></td>
<td bgcolor=LightYellow width="11%" align="center"><a href="zyDetail.jsp"><center>查看</center></a></td></tr>
<%
zy.setDat(rs.getString("DATA_SOURCES"));
zy.setApl(rs.getString("APPLICATION"));
zy.setMot(rs.getString("MOTYPE_COEFFICIENT"));
zy.setEla(rs.getString("ELASTIC_MODULUS"));
。(这部分就不写了,大家应该知道什么意思吧!)list.add(zy);
session.setAttribute("ZyForm",list);
}}
catch (ClassNotFoundException e1) {e1.printStackTrace();}
catch (SQLException e2) {e2.printStackTrace();}
catch(NullPointerException e3) {e3.printStackTrace();}
try{
rs.close();
stmt.close();
con.close();
}
catch(NullPointerException e) {e.printStackTrace();}
%>
</table>
</body>
</html>
<%@ include file="bottom.jsp" %>单个数据详细信息页面(也就是上面页面的一个链接,黄色显示处):
zyDetail.jsp<%@ page language="java" import="java.sql.*" pageEncoding="gbk" errorPage="Error.jsp"%>
<%@ page language="java" %>
<%@ page import="java.util.*"%>
<jsp:useBean id="zy" scope="page" class="form.ZyForm" scope="session"/><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>详细信息</title>
</head>
<body><table width="103%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="photo/default_04.gif" width="768" height="31" /></td>
</tr>
</table>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><span class="STYLE18">炸药数据库</span></div></td>
</tr>
</table>
<%
List l=(List)session.getAttribute("ZyForm");
for(int i = 0; i < l.size(); i++)
{
ZyForm zy=(ZyForm)l.get(i);%>
<table width="100%" height="406" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="406"><table width="80%" height="782" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" height="29"><div align="right">炸药名称:</div></td>
<td width="16%"><%=zy.getExp(i)%></td>
<td width="22%">分子式:</td>
<td width="40%"><%=zy.getMol(i)%></td>
</tr>
<tr>
<td height="32"><div align="right">应用简况:</div></td>
<td colspan="3"><%=zy.getApl(i)%></td>
</tr>
<tr>
<td height="31"><div align="right">结构式:</div></td>
<td colspan="3"><%=zy.getStr(i)%></td>
</tr>
<tr>
<td height="24">炸药性能参数</td>
</tr>
<tr>
<td height="26"><div align="right">相对分子质量:</div></td>
<td><%=zy.getRel(i)%></td>
<td><div align="right">氧平衡:</div></td>
<td><%=zy.getOxy(i)%></td>
</tr>
<tr>
<td height="29"><div align="right">蒸汽压:</div></td>
<td><%=zy.getVap(i)%></td>
<td><div align="right">熔点:</div></td>
<td><%=zy.getMel(i)%></td>
</tr>
。(这部分省略了)
</table>
</td>
</tr>
</table>
<%
}
%>
</body>
</html>
出了点错误,错误在于zydetail.jsp网页红色代码处。错误如下:ZyForm cannot be resolved to a type。我不是建了ZyForm这个类吗?而且绿色的代码把它也加到网页上了。为什么还有这个错误?
大家有意见尽管说,我是初学者。Web工程这方面才学了几天。
从zyjgQuery.jsp转到zyDetail.jsp用以上方法不知道行不行。大家给点意见。
呵呵
<jsp:useBean id="zy" scope="page" class="form.ZyForm" scope="session"/>scope="page" 指定了两次
是不是没引
form.ZyForm类
这样再导入一次试试!感觉你导入的好像是有问题啊
这样导入一次试试,感觉你导入的有问题!