当前位置: 代码迷 >> Java Web开发 >> eclipse 使用 javabean 出错,该如何处理
  详细解决方案

eclipse 使用 javabean 出错,该如何处理

热度:519   发布时间:2016-04-17 12:48:57.0
eclipse 使用 javabean 出错
我自己在做一个新闻发布系统,不太会用eclipse
错误信息为:
/WebRoot/index.jsp(3,0)   The   value   for   the   useBean   class   attribute   com.DBcon   is   invalid.
我的index页面为:
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "     errorPage= " "%>
<%@   page   import= "java.sql.* "%>
<jsp:useBean   id= "db "   class= "com.DBcon "/>
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
    <head>
       
        <title> 新闻发布 </title>
       
<meta   http-equiv= "pragma "   content= "no-cache ">
<meta   http-equiv= "cache-control "   content= "no-cache ">
<meta   http-equiv= "expires "   content= "0 ">        
<meta   http-equiv= "keywords "   content= "keyword1,keyword2,keyword3 ">
<meta   http-equiv= "description "   content= "This   is   my   page ">

    </head>
   
    <body>
        <table   align= "center "   bgcolor= "#ffff80 ">
        <tr>
        <td> 新闻标题
        </td>
        <td> 发布人
        </td>
        <td> 发布时间
        </td>
        <td>
        </td>
        </tr>
  <%
  String   sql= "select   *   from   newspub ";
  ResultSet   rs=db.executeQuery(sql);
  %>
  <%
  String   title=rs.getString( "newsTitle ");
  String   content=rs.getString( "newsContent ");
    %>
<tr>
        <td>
        <%=title%>
        </td>
        <td>
        <%=content%>
        </tr>
        </table>
        <%db.closeCon();%>
    </body>
</html>
我的bean是:
package   com;

import   java.sql.*;

public   class   DBcon   {
String   Dbdriver   =   "com.microsoft.jdbc.sqlserver.SQLServerDriver ";

String   strcon   =   "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=newspub ";

Connection   con   =   null;

Statement   stmt   =   null;

ResultSet   rs   =   null;

String   user   =   "sa ";

String   password   =   " ";

public   DBcon()   {
try   {
Class.forName(Dbdriver);
}   catch   (ClassNotFoundException   e)   {
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Sat Dec 15 13:27:54 CST 2018
  • 最近登录:Sat Dec 15 13:27:54 CST 2018
  • 最近登录:Sat Dec 15 13:27:54 CST 2018
  • 最近登录:Sat Dec 15 13:27:54 CST 2018
  • 最近登录:Sat Dec 15 13:27:54 CST 2018