如何在jsp中打印列表列表和其他类型的数据

问题描述 投票:0回答:2

我正在尝试在Spring MVC中从数据库中获取数据,这是我用于获取数据的代码

@Override
public List getOrderDetail(Integer shop_id) {
    // TODO Auto-generated method stub
    SQLQuery query = sessionFactory.getCurrentSession().createSQLQuery(
            "SELECT order_id,shop_id,delivery_address,total_amount FROM master_order WHERE shop_id =" + shop_id);

    SQLQuery query1 = sessionFactory.getCurrentSession().createSQLQuery(
            "SELECT itm.image,itm.name,itm.brand,odr.quantity,itm.offerprice,(itm.offerprice*odr.quantity) AS Total,modr.cust_id FROM master_order modr\r\n"
                    + "INNER JOIN tblorder odr ON modr.order_id = odr.order_id INNER JOIN item itm on odr.item_id = itm.item_id WHERE modr.shop_id ="+shop_id);

    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    query1.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);

    List results = query.list();
    List results1 = query1.list();

    results.add(results1);

    System.out.println(results);

    return results;
}

System.out.println(results);语句上方给出以下输出

[{shop_id=1, delivery_address=1, abc, xyz, aaa, USA, order_id=6, total_amount=1800}, [{image=Screenshot (19).png, quantity=8, Total=800, name=DhruvRajkotiya, offerprice=100, brand=gsgsrgs, cust_id=2}, {image=Screenshot (19).png, quantity=10, Total=1000, name=qwe, offerprice=100, brand=asdf, cust_id=2}, {image=Screenshot (19).png, quantity=1, Total=100, name=ewq, offerprice=100, brand=gsgsrgs, cust_id=2}]]

我要在jsp页面中打印order_id以及{image =屏幕截图(19).png,数量= 10,总数= 1000,名称= qwe,要约价格= 100,品牌= asdf,cust_id = 2}>

我如何打印

我正在尝试在Spring MVC中从数据库中获取数据,这是我的用于获取数据的代码@Override public List getOrderDetail(Integer shop_id){// TODO自动生成的方法存根SQLQuery ...

java spring hibernate jsp jstl
2个回答
0
投票
将一些数据“发送”到JSP页面的方法是设置并传递请求(或会话)属性。

0
投票
您可以将列表另存为模型属性。例如,您要保存当前用户:
© www.soinside.com 2019 - 2024. All rights reserved.