kaustubh sinha
kaustubh sinha

Reputation: 79

HTTP Status 500-Exception occuered in JSP :

I don't understand why i am getting the following error in my JSP .My controller is working accordingly i.e its returning the list properly.

Controller.java //This the controller for the jsp package 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 /This is the jsp which gets called after the controller I am using the JSTL-core taglib uri/

<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>

Upvotes: 0

Views: 314

Answers (1)

Milind J
Milind J

Reputation: 517

As per the java beans convention you should be calling customer.customerName and not customer.CustomerName in your EL.

Have a setter and getter as below.

private String customerName;

public String getCustomerName(){
  return customerName ;
}
public Void setCustomerName(String customerName){
  this.customerName = customerName ;
}

If it still does not work you are probably doing something more while retrieving the customerName like it being a JPA entity and more.

Upvotes: 1

Related Questions