jsp:setProperty 能帮我解决的给下qq,解决了,绝对给分。。。拜托拜托

确定是<jsp:setPropertyname="DBBean"property="connStr"value="jdbc:odbc:vote"/>这里传value值进去... 确定是<jsp:setProperty name="DBBean" property="connStr"value="jdbc:odbc:vote"/> 这里传value值进去出错啦,遇到过同样问题的大哥请指教啊。郁闷ing
这是bean里面的代码:

package bean;
import java.sql.*;
public class DBBean {
private Connection con=null;
private Statement stmt=null;
private String connStr;
public DBBean()
{
BulidConnection();
}
public void BulidConnection() {
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(connStr);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
public Connection getConnection()
{
if(con==null)
BulidConnection();
return con;
}
public void close()
{
try
{
con.close();
con=null;
}
catch(SQLException ex){}
}
public ResultSet excuteQuery(String sql)
{
ResultSet rs=null;
try
{
stmt=con.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.out.println(ex.getMessage());
}
return rs;
}
}

这是jsp页面的代码:
<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%>
<html>
<body>
<font size=6 color= blue>
通过Javabeans访问数据库
</font>
<jsp:useBean id="DBBean"scope="session"class="bean.DBBean"/>
<jsp:setProperty name="DBBean" property="connStr"value="jdbc:odbc:vote"/>
<%
ResultSet rs=DBBean.excuteQuery("SELECT vote.item FROM vote");
%>
<table bgcolor =red>
<td bgcolor=orange><b>电影名称</b></td>
<%
while(rs.next())
{
%>
<tr bgcolor =blue>
<td><%=rs.getString("item")%><br></td>
</tr>
<%
}
rs.close();

DBBean.close();
%>
</table>
</body>
</html>

错误内容是:

org.apache.jasper.JasperException: Cannot find any information on property 'connStr' in a bean of type 'bean.DBBean'
org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper(JspRuntimeLibrary.java:365)
org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:308)
org.apache.jsp._1_jsp._jspService(_1_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
展开
 我来答
itling
2008-10-24 · 超过21用户采纳过TA的回答
知道答主
回答量:103
采纳率:0%
帮助的人:78.5万
展开全部
在bean中加入
public void setConnStr(String str)
{
this.connStr=str;

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式