势必拿下SpringBoot 2021-06-05 18:05 采纳率: 100%
浏览 101
已结题

JSP遍历数据库中的数据遇到500的报错

这是我的遍历jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<table width="300" border="1" cellpadding="0">
      <tr>
           <th>姓名</th>
           <th>密码</th>
           <th>身份</th>
      </tr>
      
      <c:forEach var="u" items="${list}" >
      <form action="CusSelectAllServlet" method="post">
      
      <tr>
           <td><input type="text" value="${u.name}" name="name" ></td>
           <td><input type="text" value="${u.password}" name="password">
           <td><input type="text" value="${u.identity }" name="identity">
      </tr>
      
      </form>
      </c:forEach>
</table>
</body>
</html>

 这是我的Servlet的代码

package Servlet;

import java.io.IOException;
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 dao.CusDao;
import dao.CusDaoImpl;


@WebServlet("/CusSelectAllServlet")
public class CusSelectAllServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public CusSelectAllServlet() {
        super();
  
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		CusDao cd=new CusDaoImpl();
		cd.selectall();
		request.setAttribute("list", cd.selectall());
		//从Servlet跳转到showinfo.jsp页面,并且带上request和response对象中原有的参数
		request.getRequestDispatcher("/ShowAll.jsp").forward(request, response);
		
	
	}

}

 这是我的impl的方法代码

	public List<CusInformation> selectall() {
		List<CusInformation> list = new ArrayList<CusInformation>();
		try {
			String sql = "select * from customer;";
			PreparedStatement pstmt = conn.prepareStatement(sql);
			ResultSet rs = pstmt.executeQuery();
			while(rs.next()) {
				CusInformation cusinfor = new CusInformation();
				cusinfor.setName(rs.getString("cusname"));
				cusinfor.setPassword(rs.getString("cuspassword"));
				cusinfor.setIdentity(rs.getString("identity"));

				list.add(cusinfor);
				
			}
			rs.close();
			pstmt.close();
			conn.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

这是我的报错信息

HTTP Status 500 – Internal Server Error


Type Exception Report

Message java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception
javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:338)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	Servlet.CusSelectAllServlet.doPost(CusSelectAllServlet.java:39)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


Root Cause
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag
	java.lang.ClassLoader.defineClass1(Native Method)
	java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2277)
	org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:811)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1254)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
	org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1241)
	org.apache.jasper.compiler.Parser.parseElements(Parser.java:1473)
	org.apache.jasper.compiler.Parser.parse(Parser.java:145)
	org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
	org.apache.jasper.compiler.ParserController.parse(ParserController.java:105)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:201)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:333)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	Servlet.CusSelectAllServlet.doPost(CusSelectAllServlet.java:39)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


Root Cause
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.LoopTag
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
	java.lang.ClassLoader.defineClass1(Native Method)
	java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2277)
	org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:811)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1254)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
	org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1241)
	org.apache.jasper.compiler.Parser.parseElements(Parser.java:1473)
	org.apache.jasper.compiler.Parser.parse(Parser.java:145)
	org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
	org.apache.jasper.compiler.ParserController.parse(ParserController.java:105)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:201)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:333)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	Servlet.CusSelectAllServlet.doPost(CusSelectAllServlet.java:39)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


Note The full stack trace of the root cause is available in the server logs.

 拜托拜托,请指出一下我错误的地方(系统中有提示过我的jsp页面中的<form>语句中有警告)

  • 写回答

1条回答 默认 最新

  • li.siyuan 2021-06-07 14:35
    关注

    看上去好像是你使用了 不存在的标签,

    <c:forEach>

    你将这段 先注释掉 排查一下 具体是哪个地方的错误

    如果是jstl 标签库的问题的话 你可能需要排查一下 你相关的配置是否正确

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 2月4日
  • 已采纳回答 1月27日

悬赏问题

  • ¥15 系统 24h2 专业工作站版,浏览文件夹的图库,视频,图片之类的怎样删除?
  • ¥15 怎么把512还原为520格式
  • ¥15 MATLAB的动态模态分解出现错误,以CFX非定常模拟结果为快照
  • ¥15 求高通平台Softsim调试经验
  • ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
  • ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
  • ¥15 栅极驱动低侧烧毁MOSFET
  • ¥30 写segy数据时出错3
  • ¥100 linux下qt运行QCefView demo报错
  • ¥50 F1C100S下的红外解码IR_RX驱动问题