【发布时间】:2015-05-26 03:58:31
【问题描述】:
我不明白为什么我的 JSP 中出现以下错误。我的控制器正在相应地工作,即它正确返回列表。
Controller.java //这是jsp的控制器 包 com.packt.webstore.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.packt.webstore.ServiceInterface.CustomerService;
@Controller
public class CustomerController {
@Autowired
private CustomerService customerService;
@RequestMapping("/customer")
public String List(Model model){
model.addAttribute("customers",customerService.getAllCustomers());
return "customer" ;
}
}
Customer.jsp /这是在我使用 JSTL-core taglib uri 的控制器之后调用的 jsp/
<section class="container">
<div class="row">
<c:forEach items="${customers}" var="customer">
<div class="col-sm-6 col-md-3" style="padding-bottom: 15px">
<div class="thumbnail">
<div class="caption">
<p>${customer.CustomerName}</p>
<h3>${customer.CustomerID}</h3>
<p>Number of products Ordered ${customer.noOfOrderMade}</p>
</div>
</div>
</div>
</c:forEach>
</div>
</section>
【问题讨论】:
-
验证变量名可能不正确,还要在 IDE 控制台选项卡中查找异常堆栈跟踪。
-
@Rembo 谢谢。**我通过使用正确的 java 编码约定解决了我的问题,即我用 customer.customerName 替换了 customer.CustomerName。**
标签: jsp spring-mvc jstl jsp-tags