只是一个简短的jsp,想看看可以连得上不,可是白蒙蒙一片!
代码在这里
<%@ page pageEncoding="GBK" language="java" import="java.sql.*,entity.*,dao.*,dao.impl.*"  %>
<html>
<head>
</head>
<body><div>
<table cellspacing="0" cellpadding="0" width="100%">
<%
for(int i=0;i<listTopic.size();i++){
Topic topic=(Topic)listTopic.get(i);%>
<tr>
<td style="font-size:16px">
<%=topic.getboardId()%></td>
</tr>
<%
}
%>
</table>
</div>
</body>
</html>
求大神指导

解决方案 »

  1.   

    import="java.sql.*,entity.*,dao.*,dao.impl.*" 
    你这些的很霸气啊,不能这样写。一个import一个类,又不在同一个包下
      

  2.   

    你这样不显示错误太广了。
    首先的写一个测试类,测试一下你的dao是否能连接查询。
    之后再在将页面关联,如果还是出问题,就看看报什么错!
    dao没问题就是你的页面505的问题了
      

  3.   

    测试类不懂怎么写了,看到我头晕了!java我也是半桶水,麻烦你帮帮我!我把几个代码写下来,你看看!
    这个是:TopicDaoImpl 
    package dao.impl;import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.List;import entity.Topic;public class TopicDaoImpl extends BaseDao implements TopicDao {
    private Connection conn=null;
    private PreparedStatement pstmt=null;
    private ResultSet rs=null; public int addTopic(Topic topic) {
     return 0;
    } public int deleteTopic(int topic) {
    // TODO Auto-generated method stub
    return 0;
    } public int findCountTopic(int boardId) {
    // TODO Auto-generated method stub
    return 0;
    } public List findListTopic(int page, int boardId) {
    List list=new ArrayList();
    int rowBegin=0;
    if(page>1){
    rowBegin=20*(page-1);
    }
    String sql="select top 20 * from TOPIC where boardId="+boardId
    +"and topicId not in (select top"+rowBegin
    +"topicId from TOPIC where boardId="+boardId
    +"order by pblishTime desc)order by publishTime desc";
    try{
    conn=this.getConn();
    pstmt=conn.prepareStatement(sql);
    rs=pstmt.executeQuery();

    while(rs.next()){
    Topic topic=new Topic();
    topic.setTopicId(rs.getInt("topicId"));
    topic.setContent(rs.getString("content"));
    topic.setPublishTime(rs.getDate("publishTime"));
    topic.setuId(rs.getInt("uId"));
    list.add(topic);

    }
    }
    catch(Exception e){
    e.printStackTrace();
    }finally{
    this.closeAll(conn, pstmt, rs);
    }

    return list;
    } public Topic findTopic(int topicId) {
    // TODO Auto-generated method stub
    return null;
    } public int updateTopic(Topic topic) {
    // TODO Auto-generated method stub
    return 0;
    }}
    这个是TOPIC
    package entity;import java.util.Date;public class Topic {
    private int topicId;
    private String content;
    private Date publishTime;
    private int uId;
    private int boardId;
    public int getTopicId() {
    return topicId;
    }
    public void setTopicId(int topicId) {
    this.topicId = topicId;
    }
    public String getContent() {
    return content;
    }
    public void setContent(String content) {
    this.content = content;
    }
    public Date getPublishTime() {
    return publishTime;
    }
    public void setPublishTime(Date publishTime) {
    this.publishTime = publishTime;
    }
    public int getuId() {
    return uId;
    }
    public void setuId(int uId) {
    this.uId = uId;
    }
    public int getBoardId() {
    return boardId;
    }
    public void setBoardId(int boardId) {
    this.boardId = boardId;
    }
    public String toString(){
    return this.topicId+"\t"+this.boardId+"\t"+this.uId+"\t"+this.content+"\t"+this.publishTime;
    }
    }这个是TOPICDAO
    package dao.impl;import java.util.List;import entity.Topic;public interface TopicDao {
    public int addTopic(Topic topic);
    public int deleteTopic(int topic);
    public int updateTopic(Topic topic);
    public Topic findTopic(int topicId);
    public List findListTopic(int page,int boardId);
    public int findCountTopic(int boardId);}
    麻烦你帮我写个test类,谢谢
      

  4.   

    就是写一个类public class TopicDaoImplTest
    {
       public static void main(String[] args)
      {
          TopicDaoImpl dao = new TopicDaoImpl();
          List topicList =  dao.findListTopic(page, boardId);
          //之后遍历一下topicList看能不能查到东西。
          ......
      }
    }别那么发代码,看起来好吃力,幸好不多。
    我随便写写,大概就是这样
      

  5.   

    package cn.news.dao;import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;public class JDBCUtil {
    public static final String DRIVERCLASSNAME ="oracle.jdbc.driver.OracleDriver";
    public static final String URL = "jdbc:oracle:thin:@localhost:1521:accp";
    public static final String USERNAME ="scott";
    public static final String USERPWD = "tiger";

    /**
     * 加载驱动
     */
    static{
    try{
    Class.forName(DRIVERCLASSNAME);
    }catch(Exception e){
    e.printStackTrace();
    }
    }
    /**
     * 新建一个连接
     * @return
     */
        public static Connection getConn(){
         Connection conn = null;
         try{
         conn = DriverManager.getConnection(URL,USERNAME,USERPWD);
         }catch(Exception e){
         e.printStackTrace();
         }
         return conn;
        }
        

    /**
     * 关闭连接
     */
    public static void close(ResultSet rs,Statement st,Connection conn){
    try{
    if(rs!=null){
    rs.close();
    }
    }catch(Exception e){
    e.printStackTrace();
    }finally{
    try{
    if(st!=null){
    st.close();
    }
    }catch(Exception e){
    e.printStackTrace();
    }finally{
    try{
    if(conn!=null){
    conn.close();
    }
    }catch(Exception e){
    e.printStackTrace();
    }
    }
    }
    }
    }
    copy一下就可以了。不过我写的是Oracle数据库的,记得导包!
      

  6.   

    你在加一个
    public static void main(String[] args){
        Connection conn = JDBCUtil.getConn();
        Sysout.out.print(conn);
    }
    不就可以测试连接是否可用了吗!
    我也很菜的。
      

  7.   


    你不是吧,我给你的代码,那两个参数是你自己定义的,传什么你都不知道吗?
    我给的只是demo,当然不能运行,大概的我都给你了,难道你不会填充吗?
      

  8.   

    不知道你用过junit没有,如果用过,用它来测试比较方便。
      

  9.   

    嘿嘿,不好意思,我都直接抄了!后来把参数改了就可以运行test了,但是在jsp页面不显示还是不显示!!
      

  10.   

    不能显示就是你的jsp代码出问题了,发错误信息来看看