jsp中严格按照规定来

    xiaoxiao2025-05-02  13

    描述

    遇到一个奇葩问题,jsp 文件一直报错,报错位置为下面代码中的第二生,即for循环的第一行

    <c:if test="${not empty students}"> <c:forEach items="${students} " var="student"> <tr> <td>${student.studentID}</td> <td>${student.sclass }</td> <td>${student.studentName}</td> <td>${student.result }</td> </tr> </c:forEach> </c:if

    找了很久,也没能确定原因,最后将另处的正常jsp 中的for 拷过来,替换下面的代码就,没问题了,所以确定原因肯定在for 中,于是将循环体啥的,全部去除,发现还是报错,日了狗了。 于是出去转了下,回来突然想到曾经某位大神说过jsp 中不要加空格,于是注意到下面代码for 的items 中多一个空格……于是有了下面代码,测试,通过

    <c:if test="${not empty students}"> <c:forEach items="${students}" var="student"> <tr> <td>${student.studentID}</td> <td>${student.sclass }</td> <td>${student.studentName}</td> <td>${student.result }</td> </tr> </c:forEach> </c:if

    总结

    jsp 不能解析一定是代码出问题一时不能解决的问题,转一圈回来再搞,说不定灵感就来了基础还是很重要的,要深入学习基础代码多与人讨论,
    转载请注明原文地址: https://ju.6miu.com/read-1298694.html
    最新回复(0)