在线电影列表 - 观看最新电影
\u003c%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%3e\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!--\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003c!--\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003chtml%3e\u003chead%3e\u003ctitle%3e在线电影列表 - 观看最新电影\u003c/title%3e\u003c/head%3e\u003cbody%3e\u003ctable border='1' class='table table-bordered border-primary'%3e\u003ctr class='table-primary'%3e\u003cth%3e影片编号\u003c/th%3e\u003cth%3e影片名称\u003c/th%3e\u003cth%3e影片时长\u003c/th%3e\u003cth%3e影片类型\u003c/th%3e\u003cth%3e操作\u003c/th%3e\u003c/tr%3e\u003cc:forEach items='${filmList}' var='f'%3e\u003ctr%3e\u003ctd%3e${f.fid}\u003c/td%3e\u003ctd%3e${f.fname}\u003c/td%3e\u003ctd%3e${f.fduration}\u003c/td%3e\u003ctd%3e${f.ftags}\u003c/td%3e\u003ctd%3e\u003ca href='#'%3e定票\u003c/a%3e \u003c/td%3e\u003c/tr%3e\u003c/c:forEach%3e\u003c/table%3e\u003c/body%3e\u003c/html%3e\u003c!--\u003c%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%3e\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003c!--\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003chtml%3e\u003chead%3e\u003ctitle%3e在线电影列表 - 观看最新电影\u003c/title%3e\u003c/head%3e\u003cbody%3e\u003ctable border='1' class='table table-bordered border-primary'%3e\u003ctr class='table-primary'%3e\u003cth%3e影片编号\u003c/th%3e\u003cth%3e影片名称\u003c/th%3e\u003cth%3e影片时长\u003c/th%3e\u003cth%3e影片类型\u003c/th%3e\u003cth%3e操作\u003c/th%3e\u003c/tr%3e\u003cc:forEach items='${filmList}' var='f'%3e\u003ctr%3e\u003ctd%3e${f.fid}\u003c/td%3e\u003ctd%3e${f.fname}\u003c/td%3e\u003ctd%3e${f.fduration}\u003c/td%3e\u003ctd%3e${f.ftags}\u003c/td%3e\u003ctd%3e\u003ca href='#'%3e定票\u003c/a%3e \u003c/td%3e\u003c/tr%3e\u003c/c:forEach%3e\u003c/table%3e\u003c/body%3e\u003c/html%3e\u003c!--\u003c%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%3e\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003c!--\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003chtml%3e\u003chead%3e\u003ctitle%3e在线电影列表 - 观看最新电影\u003c/title%3e\u003c/head%3e\u003cbody%3e\u003ctable border='1' class='table table-bordered border-primary'%3e\u003ctr class='table-primary'%3e\u003cth%3e影片编号\u003c/th%3e\u003cth%3e影片名称\u003c/th%3e\u003cth%3e影片时长\u003c/th%3e\u003cth%3e影片类型\u003c/th%3e\u003cth%3e操作\u003c/th%3e\u003c/tr%3e\u003cc:forEach items='${filmList}' var='f'%3e\u003ctr%3e\u003ctd%3e${f.fid}\u003c/td%3e\u003ctd%3e${f.fname}\u003c/td%3e\u003ctd%3e${f.fduration}\u003c/td%3e\u003ctd%3e${f.ftags}\u003c/td%3e\u003ctd%3e\u003ca href='#'%3e定票\u003c/a%3e \u003c/td%3e\u003c/tr%3e\u003c/c:forEach%3e\u003c/table%3e\u003c/body%3e\u003c/html%3e\u003c!--\u003c%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%3e\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003c!--\u003c%@ page contentType='text/html;charset=UTF-8' language='java'%3e\u003c!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'--%3e\u003chtml%3e\u003chead%3e\u003ctitle%3e在线电影列表 - 观看最新电影\u003c/title%3e\u003c/head%3e\u003cbody%3e\u003ctable border='1' class='table table-bordered border-primary'%3e\u003ctr class='table-primary'%3e\u003cth%3e影片编号\u003c/th%3e\u003cth%3e影片名称\u003c/th%3e\u003cth%3e影片时长\u003c/th%3e\u003cth%3e影片类型\u003c/th%3e\u003cth%3e操作\u003c/th%3e\u003c/tr%3e\u003cc:forEach items='${filmList}' var='f'%3e\u003ctr%3e\u003ctd%3e${f.fid}\u003c/td%3e\u003ctd%3e${f.fname}\u003c/td%3e\u003ctd%3e${f.fduration}\u003c/td%3e\u003ctd%3e${f.ftags}\u003c/td%3e\u003ctd%3e\u003ca href='#'%3e定票\u003c/a%3e \u003c/td%3e\u003c/tr%3e\u003c/c:forEach%3e\u003c/table%3e\u003c/body%3e\u003c/html%3e', 'package servlet;
import model.Film;import service.impl.QueryAllFilmServiceImpl;import util.JdbcUtil;
import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.sql.Connection;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;
/** * @author 高蒙蒙 * @date 2023/8/15 12:25 */@WebServlet('/FilmServlet')public class FilmServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { List\u003cFilm\u003efilmList = new QueryAllFilmServiceImpl().queryAllFilm(); req.setAttribute('filmList', filmList); req.getRequestDispatcher('/index.jsp').forward(req, resp); }}index.jsp页面接收不到显示名为'filmList'的请求属性内容:There are a few possible reasons why the index.jsp page may not be receiving the 'filmList' request attribute:
-
The 'filmList' attribute is not set in the FilmServlet: Make sure that the 'filmList' attribute is set correctly in the FilmServlet before forwarding the request to the index.jsp page. Double-check the implementation of the QueryAllFilmServiceImpl and ensure that it is returning a valid List\u003cFilm\u003e object.
-
The 'filmList' attribute is not being forwarded correctly: Verify that the req.getRequestDispatcher('/index.jsp').forward(req, resp) statement is being executed and that the request is being forwarded to the correct path ('/index.jsp'). Check for any typos or incorrect paths in the forward statement.
-
The JSTL taglib is not properly imported: Ensure that the JSTL taglib is imported correctly at the beginning of the index.jsp file. The taglib declaration should be as follows:\u003c%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%3e
-
The JSTL library is not included in the project: Make sure that the JSTL library (jstl.jar or jstl-1.2.jar) is included in the project's build path. If the library is missing, you can download it from the official Apache website and add it to your project.
-
The JSTL core tags are not used correctly: Double-check the usage of the c:forEach tag in the index.jsp file. Ensure that the 'filmList' attribute is correctly referenced within the tag as '${filmList}'.
By addressing these potential issues, you should be able to resolve the problem and have the index.jsp page receive the 'filmList' request attribute successfully.
原文地址: https://www.cveoy.top/t/topic/qkZ7 著作权归作者所有。请勿转载和采集!