繁体   English   中英

从春季的控制器传递时,Java数据未显示在JSP VIW中

[英]java data not showing in jsp viw when passing from controller in spring

鉴于$ {item}值未显示在view.i中,这是java spring的新功能。请帮助我。

<c:forEach items="${billItems}" var="item" varStatus="loop">
        ${item}
       <%-- <tr class="text_center border_left">
            <td ></td>
            <td >${loop.index + 1}</td>
            <td >${item.code}  # ${item.productName} </td>
            <td>${item.quantity}</td>
            <td>${item.unit}</td>
            <td class="col-integer">${item.price}</td>
            <td class="col-integer">${item.quantity * item.price}</td>
            <td></td>
            <c:set var="temp" value="${item.quantity * item.price}"/>
            <c:set var="total" value="${total + temp}"/>
        </tr>--%>
    </c:forEach>'

鉴于$ {item}值未在视图中显示。我是java spring的新功能。请帮助我。控制器在下面

@RequestMapping(value = "/billing/print/{id}", method = RequestMethod.GET)
public String billPrint(@PathVariable int id, Model model, HttpServletRequest request)
        throws IllegalStateException, IOException {
    if (request.getSession().getAttribute("loginUser") != null) {
        Bill bill;
        bill = obsJDBCTemplate.getLastBillForPrinting(id);
        Customer customer = obsJDBCTemplate.getCustomer(bill.getCustomerId());
        bill.setCustomerName(customer.getName());

        List<BillItem> billItems = obsJDBCTemplate.getBillItemList(bill.getBillId());

        for (BillItem billItem : billItems) {
            Product product = obsJDBCTemplate.getProduct(billItem.getIdproduct());
            billItem.setProductName(product.getName());
            billItem.setCode(product.getCode());
            billItem.setUnit(product.getUnit());
        }

        model.addAttribute("billItems", billItems);
        model.addAttribute("h1_label","Irfan Mughal");
        model.addAttribute("h4_br1","jewen hanna hassan mobile center garden town Lahore");
        model.addAttribute("h4_br2","");
        model.addAttribute("h4_br3","");
        model.addAttribute("bill", bill);
        model.addAttribute("previous_balance", obsJDBCTemplate.getDebitOfCustomer(customer.getIdCustomer()));
        return "Print";

    } else
        return "redirect:/";

}

您是否具有正确的taglib标头<%@ taglib前缀=“ c” uri =“ http://java.sun.com/jsp/jstl/core ”%>,否则,不会导致spring模型出现问题对象。 看看http://www.mkyong.com/spring-mvc/spring-mvc-hello-world-example/这是一个很好的起点

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM