JSP Servlet 的 org.apache.jasper.JasperException [重复]

Posted

技术标签:

【中文标题】JSP Servlet 的 org.apache.jasper.JasperException [重复]【英文标题】:org.apache.jasper.JasperException for JSP Servlet [duplicate] 【发布时间】:2021-06-04 05:38:39 【问题描述】:

我正在创建我的第一个 JSP servlet,但遇到了一个我不明白的问题。程序很简单

我有两个部分:

一个java+jsp添加新行 显示这些行的 java+jsp

我正在加载网址: http://localhost/test/addUf.jsp

我填写字段,单击按钮。数据库插入没问题,我现在被重定向到 http://localhost/test/servletRecord

当它尝试加载此页面时出现我的问题:

05-Mar-2021 12:29:45.046 INFOS [Catalina-utility-1] org.apache.catalina.core.StandardContext.reload Le rechargement de ce contexte est terminé
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP
    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:605)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:423)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at servletRecord.doGet(servletRecord.java:71)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:621)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400)
    ... 37 more
Caused by: java.lang.IllegalArgumentException: Directive de page : valeur invalide pour import
    at org.apache.jasper.compiler.Node$PageDirective.validateImport(Node.java:619)
    at org.apache.jasper.compiler.Node$PageDirective.addImport(Node.java:599)
    at org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:366)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:478)
    at org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1797)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:141)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
    at org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:127)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:202)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:386)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:605)
    ... 38 more
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP
    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:605)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:423)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at servletRecord.doGet(servletRecord.java:71)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:621)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400)
    ... 37 more
Caused by: java.lang.IllegalArgumentException: Directive de page : valeur invalide pour import
    at org.apache.jasper.compiler.Node$PageDirective.validateImport(Node.java:619)
    at org.apache.jasper.compiler.Node$PageDirective.addImport(Node.java:599)
    at org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:366)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:478)
    at org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1797)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:141)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
    at org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:127)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:202)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:386)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:605)
    ... 38 more

这是我的文件: addUF.java

import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;
import com.microsoft.sqlserver.jdbc.*;

public class addUf extends HttpServlet 
 
   public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
    
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        Connection connBDUtil = null;
        
        String id_config = request.getParameter("id_config").toString();
        String uf_code = request.getParameter("uf_code").toString();
        String libelle = request.getParameter("libelle").toString();
        String nbLits = request.getParameter("nbLits").toString();
        String actif = "1";
        if(request.getParameter("actif")== null) actif = "0";
        
        Statement stmt;
        try SQLServerDataSource ds_BD_util = new SQLServerDataSource();
        
            ds_BD_util.setUser(db.UserBD_util);
            ds_BD_util.setPassword(db.PasswordBD_util);
            ds_BD_util.setServerName(db.ServerNameBD_util);
            ds_BD_util.setPortNumber(db.PortNumberBD_util);
            ds_BD_util.setDatabaseName(db.DatabaseNameBD_util);
            connBDUtil = ds_BD_util.getConnection();                
            
            System.out.println("Connected to the database");
            
            //test de validité
        
            String sqlText = "INSERT INTO LitsConfig (id_config, uf_code, libelle, nbLits, actif) " +
                    "VALUES ('" + id_config + "', '" + uf_code + "', '" + libelle + "', '" + nbLits + "', '" + actif +"')" ;
        
            System.out.println("SQL : " + sqlText);
        
            stmt = connBDUtil.createStatement();
        
            int i = stmt.executeUpdate(sqlText);
            System.out.println("query" + sqlText);
            if(i>0)
            
                response.sendRedirect("servletRecord");
            
            connBDUtil.close();
            System.out.println("Disconnected from database");
         
        catch (Exception e) 
        
            e.printStackTrace();
        
    

添加UF.jsp

<html>
<head></head>
<body>
    <form name="userform" method="post" action="addUf">
    <br><br><br>
        <table align="center"  style="background-color:#EDF6EA;border:1px solid #000000;">
        <tr><td colspan=2 style="font-weight:bold;" align="center">Ajouter une UF</td></tr>
        <tr><td colspan=2 align="center" ></td></tr>
            <tr>
                <td style="font-weight:bold;">Id config</td>
                <td><input type="text" name="id_config" value=""></td>
            </tr
            
            <tr>
                <td style="font-weight:bold;">UF</td>
                <td><input type="text" name="uf_code" value=""></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Libellé</td>
                <td><input type="text" name="libelle" value=""></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Nombre de lits</td>
                <td><input type="text" name="nbLits" value=""></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">actif</td>
                <td><input type="checkbox" name="actif" value=""></td>
            </tr>
            
            <tr>
                <td></td>
                <td><input type="submit" name="Submit" value="Ajouter" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
            </tr>
            <tr><td colspan=2 align="center" ></td></tr>
        </table>
    </form>
</body>
</html>

servletRecord.java

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;
import com.microsoft.sqlserver.jdbc.*;

public class servletRecord extends HttpServlet 
 
   public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
    
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
    
        Connection connBDUtil = null;
        
        Statement stmt;
        
        try 
           
            SQLServerDataSource ds_BD_util = new SQLServerDataSource();
            
            ds_BD_util.setUser(db.UserBD_util);
            ds_BD_util.setPassword(db.PasswordBD_util);
            ds_BD_util.setServerName(db.ServerNameBD_util);
            ds_BD_util.setPortNumber(db.PortNumberBD_util);
            ds_BD_util.setDatabaseName(db.DatabaseNameBD_util);
            connBDUtil = ds_BD_util.getConnection();
        
            System.out.println("Connected to the database");
            
            ArrayList arrayConfig = null;
            ArrayList litsConfigList = new ArrayList();
            
            String sqlText = "SELECT * FROM LitsConfig ORDER BY libelle";
            System.out.println("sqlText " + sqlText);
            
            stmt = connBDUtil.createStatement();
            ResultSet  rs = stmt.executeQuery(sqlText);

            while(rs.next())
            
                arrayConfig  = new ArrayList();
            
                arrayConfig.add(rs.getInt(1));      // Id Config
                arrayConfig.add(rs.getString(2));   // Ufs
                arrayConfig.add(rs.getString(3));   // Libellé
                arrayConfig.add(rs.getInt(4));      // Nb Lits
                arrayConfig.add(rs.getInt(5));      // Actif
              
                System.out.println("arrayConfig :: "+arrayConfig);
                litsConfigList.add(arrayConfig);
            

            request.setAttribute("litsConfigList", litsConfigList);
            
            String nextJSP = "/home.jsp";
            RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
            dispatcher.forward(request,response);
            
            ConnEasily.close();
            connBDUtil.close();
            System.out.println("Disconnected from database");           
         
        catch (Exception e) 
        
            e.printStackTrace();
        
    

home.jsp

<%@ page language="java" import="java.util.*;"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>Occupation des lits de pédiatrie</TITLE>
  
  <script language="javascript">
    function editrecord(id)       
        window.location.href="editServlet/"+id; 
      


      function deleteRecord(id)       
        window.location.href="deleteUser/"+id; 
      
</script>
 </HEAD>

 <BODY>
 <br>
<table align="center">
  
</table>
<br>
  <table   align="center" style="background-color:#EDF6EA;border:1px solid #000000;">
    <tr><td colspan=9 align="center" ></td></tr>

    <tr><td colspan=9 align="center"><a href="addUf.jsp" style="font-weight:bold;color:#cc0000;">Ajouter une configuration d'UF</a></td></tr>
    <tr><td colspan=9 align="center" ></td></tr>

    <tr style="background-color:#7BA88B;font-weight:bold;">
     <td>Config Id</td>
     <td>Codes UF</td>
     <td>Libellé</td>
     <td>Nombre de lits</td>
     <td>Actif</td>  
     <td>Edit</td>
     <td>Delete</td>
    </tr>
  
    <%
    String bgcolor="";
    int count=0;
    List viewList = new ArrayList();
    Iterator  viewitrLitsConfig;
    
    if(request.getAttribute("litsConfigList")!=null && request.getAttribute("litsConfigList")!="")
    
        List litsConfigList =  (ArrayList)request.getAttribute("litsConfigList");
        Iterator itrLitsConfig = litsConfigList.iterator();
        
        while(itrLitsConfig.hasNext())
        
            
            if(count%2==0)
            
             bgcolor = "#C8E2D1";
            
            else
            
                
                bgcolor = "#EAF8EF";
            
            
            viewList = (ArrayList)itrLitsConfig.next();
            int id = Integer.parseInt(viewList.get(0).toString());
            viewitrLitsConfig = viewList.iterator();
            %>
            <tr style="background-color:<%=bgcolor%>;">
            <%  
            while(viewitrLitsConfig.hasNext())
            
            
                %>
                <td><%=viewitrLitsConfig.next()%></td>
                
                <%
                    
            
            count++;
            %>
                <td><input type="button" name="edit" value="Edit" style="background-color:#49743D;font-weight:bold;color:#ffffff;" onclick="editRecord(<%=id%>);" ></td>
                <td><input type="button" name="delete" style="background-color:#ff0000;font-weight:bold;;color:#ffffff;" value="Delete" onclick="deleteRecord(<%=id%>);"></td>
            </tr>
            <%
        
    
    if(count==0)
    
        %>
        <tr><td colspan="9" align="center">&nbsp;</td></tr>
            <tr><td colspan="9" align="center">Aucun enregistrement disponible</td></tr>
        <%
    
    %>
    <tr><td colspan=9 align="center" ></td></tr>
  </table>  
 </BODY>
</HTML>

web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<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_2_5.xsd"
   version="2.5">

  <display-name>Test Config</display-name>
  <description>Test Config</description>
 
 <servlet>
     <servlet-name>servletrecord</servlet-name>
     <servlet-class>servletRecord</servlet-class>
 </servlet>
 <servlet-mapping>
     <servlet-name>servletrecord</servlet-name>
     <url-pattern>/servletRecord</url-pattern>
 </servlet-mapping>


 <servlet>
    <servlet-name>addUf</servlet-name>
    <servlet-class>addUf</servlet-class>
 </servlet>
 <servlet-mapping>
    <servlet-name>addUf</servlet-name>
    <url-pattern>/addUf</url-pattern>
 </servlet-mapping>

 <servlet>
  <servlet-name>editservlet</servlet-name>
  <servlet-class>userServlet</servlet-class>
 </servlet>
 <servlet-mapping>
    <servlet-name>editservlet</servlet-name>
    <url-pattern>/editServlet/*</url-pattern>
 </servlet-mapping>

 <servlet>
    <servlet-name>edituser</servlet-name>
    <servlet-class>editUser</servlet-class>
 </servlet>
 <servlet-mapping>
    <servlet-name>edituser</servlet-name>
    <url-pattern>/editUser</url-pattern>
 </servlet-mapping>

<servlet>
    <servlet-name>deleteuser</servlet-name>
    <servlet-class>deleteUser</servlet-class>
</servlet>
 <servlet-mapping>
    <servlet-name>deleteuser</servlet-name>
    <url-pattern>/deleteUser/*</url-pattern>
 </servlet-mapping>

</web-app>

我错过了什么?

我的库是: ojdbc6.jar servlet-api.jar sqljdbc.jar

感谢您的帮助! 雄猫 9 / Java 8

【问题讨论】:

您的page 指令(import 属性)中有语法错误。检查this answer 的语法是否正确。 BTW 脚本&lt;% ... %&gt; 应该替换为EL expressions 和JSTL。所有的准备工作都应该在servletRecord中完成(奇怪的名字,Java中的类名应该以大写字母开头)。 谢谢,它成功了。关于类名的大写,我同意,这是来自教程,我没有重写它。我阅读了你关于 EL 表达式和 JSTL 的链接,但我没有掌握背后的概念。你能告诉我如何将我的部分代码翻译成 JSTL 以便我理解吗? 【参考方案1】:

消息是由import="java.util.*;" 属性引起的,它应该是import="java.util.*"(参见this answer)。

但是,从 JSP 2.0 开始,不鼓励使用脚本 &lt;% … %&gt;,而是使用 EL 表达式 $ … 和 JSTL 标记。假设你有一个像这样的JavaBean 类:

public class LitsConfig 

    private int     id;
    private String  codeUf;
    private String  libelle;
    private int     noLits;
    private boolean actif;

    // getters and setters
    ...

为了表示您的行数据并假设您的 servlet 将类型为 List&lt;LitsConfig&gt; 的名为 "litsConfig" 的属性放入请求上下文中,您可以像这样简化您的 JSP 页面:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
table.main 
    width: 600px;
    margin: auto;
    background-color: #EDF6EA;
    border: 1px solid #000000;

tr.header 
    background-color: #7BA88B;
    font-weight: bold;

tr.data:nth-child(odd) 
    background-color: #C8E2D1;

tr.data:nth-child(even) 
    background-color: #EAF8EF;

</style>
</head>
<body>
  <table class="main">
    <tr class="header">
      <td>Config Id</td>
      <td>Codes UF</td>
      <td>Libellé</td>
      <td>Nombre de lits</td>
      <td>Actif</td>
      <td>Edit</td>
      <td>Delete</td>
    </tr>
    <!--
     Iterates over each element of the request attribute `litsConfig`.
     The element is available as the page attribute `lit`.
     -->
    <c:forEach items="$litsConfig" var="lit">
      <tr class="data">
        <td>$lit.id</td>
        <td>$lit.codeUf</td>
        <td>$lit.libelle</td>
        <td>$lit.noLits</td>
        <td>$lit.actif ? "oui" : "non" </td>
        <td><a href="$contextPath/editServlet/$lit.id">Éditer</a></td>
        <td><a href="$contextPath/deleteUser/$lit.id">Effacer</a></td>
      </tr>
    </c:forEach>
    <!-- Adds a row if `litsConfig` is empty (or not defined) -->
    <c:if test="$fn:length(litsConfig) == 0">
      <tr>
        <td colspan="9" align="center">Aucun enregistrement disponible</td>
      </tr>
    </c:if>
  </table>
</body>
</html>

备注:您需要将taglibs-standard-spec.jartaglibs-standard-impl.jar 添加到您的依赖项中。

【讨论】:

非常感谢 :) 如果我做对了,这个想法是使用 java 对象来模拟我的表而不是通用数组? 主要思想是完全替换 JSP 中的 Java 代码(参见 [this answer])。使用JavaBeans 只是让JSP 更具可读性的一种方式。

以上是关于JSP Servlet 的 org.apache.jasper.JasperException [重复]的主要内容,如果未能解决你的问题,请参考以下文章

求高手解决严重: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException

Servlet.service() for servlet jsp threw exception

javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN

已解决:java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.com.yourproject.test_jsp

java.lang.NoClassDefFoundError: org/apache/jsp/Index_jsp

JSP异常之org.apache.jasper.JasperException(转)