Почему не выводит данные в jsp ($id, $name..)
Не выводит данные из List Servlet
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List<Flower> flowers = flowerBusinessService.getFlowers();
//HttpSession session = request.getSession(false); //Убрать true
//session.setAttribute("flowers", flowers);
request.setAttribute("flowers", flowers);
request.getRequestDispatcher("/flowers.jsp").forward(request, response);
}
JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="com.be.entity.Flower"%>
<%@ taglib prefix="page" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css"
integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="css/flowershop.css">
<title>Flowers</title>
</head>
<body>
<div>
<table class="table">
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<c:forEach items="${flowers}" var="fl" varStatus="rowStatus">
<tr>
<td>${fl.id}</td>
<td>${fl.name}</td>
<td>${fl.price}</td>
<td>${fl.quantity}</td>
</tr>
</c:forEach>
</table>
</div>
<button type="button" name="back" class="submit-button" onclick="history.back()">back</button>
</body>
</html>
Вывод:
Ответы (1 шт):
Автор решения: Джейк Морган
→ Ссылка
Решение: Проверить web.xml на присутствие
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
