HTTP Status 500 - javax.el.PropertyNotFoundException: Property not found on type
Cервлет должен принимать список meals и отображать таблицу. ловлю ошибку, помогите понять в чем проблема?
Model - Meal
public class Meal {
private final LocalDateTime dateTime;
private final String description;
private final int calories;
public Meal(LocalDateTime dateTime, String description, int calories) {
this.dateTime = dateTime;
this.description = description;
this.calories = calories;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public String getDescription() {
return description;
}
public int getCalories() {
return calories;
}
public LocalDate getDate() {
return dateTime.toLocalDate();
}
public LocalTime getTime() {
return dateTime.toLocalTime();
}
}
MealTo
public class MealTo {
private final LocalDateTime dateTime;
private final String description;
private final int calories;
private final boolean excess;
public MealTo(LocalDateTime dateTime, String description, int calories, boolean excess) {
this.dateTime = dateTime;
this.description = description;
this.calories = calories;
this.excess = excess;
}
@Override
public String toString() {
return "MealTo{" +
"dateTime=" + dateTime +
", description='" + description + '\'' +
", calories=" + calories +
", excess=" + excess +
'}';
}
}
MealServlet
public class MealServlet extends HttpServlet {
private static final Logger log = getLogger(MealServlet.class);
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.debug("redirect to meals");
List<MealTo> meals = Arrays.asList(
new MealTo(LocalDateTime.of(2020, Month.JANUARY, 30, 10, 0), "Завтрак", 500, false),
new MealTo(LocalDateTime.of(2020, Month.JANUARY, 30, 13, 0), "Обед", 1000, false),
new MealTo(LocalDateTime.of(2020, Month.JANUARY, 30, 20, 0), "Ужин", 500, false),
new MealTo(LocalDateTime.of(2020, Month.JANUARY, 31, 0, 0), "Еда на граничное значение", 100, true),
new MealTo(LocalDateTime.of(2020, Month.JANUARY, 31, 10, 0), "Завтрак", 1000, true),
new MealTo(LocalDateTime.of(2020, Month.JANUARY, 31, 13, 0), "Обед", 500, true),
new MealTo(LocalDateTime.of(2020, Month.JANUARY, 31, 20, 0), "Ужин", 400, true)
);
request.setAttribute("meals", meals);
request.getRequestDispatcher("/meals.jsp").forward(request, response);
}
}
meals.jsp
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html lang="ru">
<head>
<title>Meals</title>
</head>
<body>
<h3><a href="index.html">Home</a></h3>
<hr>
<h2>Meals</h2>
<table>
<thead>
<tr>
<td style="color: black"></td>
<td>Date</td>
<td>Description</td>
<td>Calories</td>
</tr>
</thead>
<tbody>
<jsp:useBean id="meals" scope="request" type="java.util.List"/>
<c:forEach var="meal" items="${meals}">
<tr>
<td>
<fmt:parseDate value="${ meal.dateTime }" pattern="yyyy-MM-dd'T'HH:mm" var="parsedDateTime"
type="both"/>
<fmt:formatDate pattern="dd.MM.yyyy HH:mm" value="${ meal.dateTime }"/>
</td>
<td><c:out value="${meal.descriptions}"/></td>
<td><c:out value="${meal.calories}"/></td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
