jsp c:列表

时间:2016-04-13 21:30:41

标签: spring jsp jstl

显示产品清单的问题

不要展示ProductDTO类产品 我的jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>...
        ...<c:forEach var="ProductDTO" items="${products}" varStatus="loop"></c:forEach>
        <tr>
            <td><c:out value="${ProductDTO.getDescription()}"/></td>
            <td><c:out value="${ProductDTO.getName() }"/></td>
        </tr>...

控制器

    @RequestMapping("/marketplace")
public String marketplace(Model model) {
    if (!userSession.isInLoged())
        return "redirect:login";
    List<ProductDTO> products=productDAO.getAll();
    model.addAttribute("products",products);
    return "marketplace";

}

ProductDao这个

public List<ProductDTO> getAll() {
    String sql = "SELECT* FROM epam_db.products";
    List<ProductDTO> products = jdbcTemplate.query(sql, new ProductMapper());
    if (products.isEmpty())
        return null;
    return products;
}

ProductDTO 包dto;

import java.sql.Date;

public class ProductDTO {
    private int idProducts;
    private String name;
    private String description;
    private Date startDate;
    private int quantity;
    private double price;
    private int users_idusers;
    // getters and setters........
}

0 个答案:

没有答案