本帖最后由 marthok 于 2012-05-29 18:47:40 编辑

解决方案 »

  1.   


    jsp页面改成<form action="<%=request.getContextPath()%>/Servlet/Export" method="post">
      

  2.   


    500是没有找到Result这个类,检查jar包是否加入
      

  3.   

    这个我试过了。 照样错误。  有一点,其他的servlet都是对的,唯独这一个,   把人折腾三天了。
      

  4.   


    如果是这个问题的话就更奇怪了啊。 应为我不止在这一个地方用到Result这个类。 我在DB里面也用上了Result这个类 进行查询传递list  而且没报错。 如下package com.outher.tongji;import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;import javax.servlet.jsp.jstl.sql.Result;
    import javax.servlet.jsp.jstl.sql.ResultSupport;import com.bean.*;
    import com.util.MasDbPool;public class TimeQueryDB {

    public static int getGMethod(String SQL,String startTime,String endTime){
            int i = 0;

    String sql =SQL;

    Connection conn = null;

    PreparedStatement ps = null;

    ResultSet rs = null;

    try{

    conn = MasDbPool.getConnection();

    ps = conn.prepareStatement(sql);

        ps.setString(1, endTime);

    ps.setString(2, startTime);

    rs = ps.executeQuery();

    if(rs.last())i=rs.getRow();

    }catch(Exception e){

    e.printStackTrace();

    }finally{
    MasDbPool.dbClose(conn, ps, null, rs);
    }
    System.out.println(i);
    return i;
    }


    //时间段查询全部数量
    public static int getTimeQueryNums(String startTime,String endTime){
    String sql ="select * from timequery where substring(time,1,10)<=? and substring(time,1,10)>=?";
    return getGMethod(sql,startTime,endTime);
    }

    //时间段查询维修数量
    public static int getWxNumbers(String startTime,String endTime){
    String sql ="select * from mlipeiwxbaobiao where substring(time,1,10)<=? and substring(time,1,10)>=?";
    return getGMethod(sql,startTime,endTime);
    }

    //时间段查询完结数量
    public static int getWjNumbers(String startTime,String endTime){
    String sql ="select * from mlipeiwjbaobiao where substring(time,1,10)<=? and substring(time,1,10)>=?";
    return getGMethod(sql,startTime,endTime);
    }

    //时间段查询手续数量
    public static int getSxNumbers(String startTime,String endTime){
    String sql ="select * from mlipeisxbaobiao where substring(time,1,10)<=? and substring(time,1,10)>=?";
    return getGMethod(sql,startTime,endTime);
    }

        public static void main(String[] args) {
    System.out.println(getTimeQuery("2012-05-04","2012-05-24").size());

    }
        //查询这个时间段
        public static List<TimeQueryBean> getTimeQuery(String startTime,String endTime){
    String sql ="select * from timequery where substring(time,1,10)<=? and substring(time,1,10)>=?";
    Connection conn = null;

    List<TimeQueryBean> list=new ArrayList<TimeQueryBean>();

    PreparedStatement ps = null;

    ResultSet rs = null;

    Result result=null;

    try{

    conn = MasDbPool.getConnection();

    ps = conn.prepareStatement(sql);

        ps.setString(1, endTime);

    ps.setString(2, startTime);

    rs = ps.executeQuery();

    result=ResultSupport.toResult(rs);

    if(result!=null&&result.getRowCount()>0){
    //for(int i=0;result.getRowCount()>i;i++){
    Map map[]=result.getRows();
    for(int k=0;k<map.length;k++){
    String jieguo=map[k].get("jieguo").toString();
    String chepai=map[k].get("chepai").toString();
    String leixing=map[k].get("leixing").toString();
    String phone=map[k].get("phone").toString();
    String picctype=map[k].get("picctype").toString();
    String time=map[k].get("time").toString();
    TimeQueryBean bean=new TimeQueryBean(time,jieguo,leixing,chepai,picctype,phone);
    list.add(bean);
    }
    //}
    }
    System.out.println(result.getRowCount());

    }catch(Exception e){

    e.printStackTrace();

    }finally{
    MasDbPool.dbClose(conn, ps, null, rs);
    }
    return list;
    }

    }
      

  5.   


    应该是jdk版本的问题。     直接把result遍历放入list后就好啦。  也不整result了