2 sipichen sipichen 于 2014.11.19 10:41 提问

链表的add不执行也不报错

求大神解答,products是范型为Product的List,执行到products.add(product)的时候总是停下,也不报错,这是什么原因啊?

6个回答

sipichen
sipichen   2014.11.19 10:42
已采纳
Product product = new Product();
        product = gDao.get(Product.class, sql, id);
        String attrnameids = product.getAttrname();
        String []attrnameids2 = attrnameids.split("#");
        for(int i=0;i<attrnameids2.length;i++)
        {
            description += gDao.qureystr(sql3, attrnameids2[i])+",";
        }

        description = description.substring(4, description.length()-1);
        product.setDescription(description);

        int fid = product.getFid();
        String fname = gDao.qureystr(sql2, fid);
        product.setFactory(fname);

        String pic = path+product.getPic();
        product.setPic(pic);

        product.setCount("1");

        System.out.println("4");
        products.add(product);
        System.out.println("6");
        session.setAttribute("products", products);
qq_21392937
qq_21392937   2014.11.19 11:40

可能并不是你这段代码的问题,我记得之前我也遇到过,并不是这里有问题

HOUWEI0308
HOUWEI0308   2014.11.19 13:46

Product product = new Product();
product = gDao.get(Product.class, sql, id);
String attrnameids = product.getAttrname();
String []attrnameids2 = attrnameids.split("#");
for(int i=0;i<attrnameids2.length;i++)
{
description += gDao.qureystr(sql3, attrnameids2[i])+",";
}

    description = description.substring(4, description.length()-1);
    product.setDescription(description);

    int fid = product.getFid();
    String fname = gDao.qureystr(sql2, fid);
    product.setFactory(fname);

    String pic = path+product.getPic();
    product.setPic(pic);

    product.setCount("1");

    System.out.println("4");
    products.add(product);
    System.out.println("6");
    session.setAttribute("products", products);
HOUWEI0308
HOUWEI0308   2014.11.19 13:46

Product product = new Product();
product = gDao.get(Product.class, sql, id);
String attrnameids = product.getAttrname();
String []attrnameids2 = attrnameids.split("#");
for(int i=0;i<attrnameids2.length;i++)
{
description += gDao.qureystr(sql3, attrnameids2[i])+",";
}

    description = description.substring(4, description.length()-1);
    product.setDescription(description);

    int fid = product.getFid();
    String fname = gDao.qureystr(sql2, fid);
    product.setFactory(fname);

    String pic = path+product.getPic();
    product.setPic(pic);

    product.setCount("1");

    System.out.println("4");
    products.add(product);
    System.out.println("6");
    session.setAttribute("products", products);
jinfengyiye
jinfengyiye   2014.11.21 13:35

在执行吗?会一直卡吗?

caozhy
caozhy   Ds   Rxr 2014.11.21 13:38

什么叫“停下“,你是用什么执行的,建议编译后执行,或者换一个IDE试试看,建议用Eclipse

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!