页面报错?JSTL使用不了?

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

3回答
一叶知秋519 2018-04-23 16:59:18

http://img1.sycdn.imooc.com//climg/5adda01b000181cd05730199.jpg

foEach,E是大写的;

另外var="int"改为var="a",尽量避免与关键字重名。修改以后注意修改其他用到的地方。

祝学习愉快!

提问者 liqihang 2018-04-23 16:47:01

http://img1.sycdn.imooc.com//climg/5add9d730001054210010322.jpg

package com.imooc.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;

/**
 * Servlet implementation class Jstl
 */
@WebServlet("/Jstl")
public class Jstl extends HttpServlet {
 private static final long serialVersionUID = 1L;
      
  
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      int[] a=new int[101];
      for(int i=0,j=100;i<a.length;i++){
       a[i]=j;
       j++;
       System.out.println(a[i]);
      }
      request.setAttribute("array", a);
      request.getRequestDispatcher("/JSETjsp.jsp").forward(request, response);
 }

 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
  doGet(request, response);
 }

}

<%@ 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>JSTL练习</title>
</head>
<body>
<c:out value="既能被4整除又能被5整除的数据有:"></c:out>
<c:foreach items="${array}" var="int">
<c:if test="${int%4==0&&int%5==0}">
 <c:out value="${int}"></c:out>
</c:if>
</c:foreach>
</body>
</html>

好帮手慕珊 2018-04-23 15:51:36

是否导入jar包了?

  • 提问者 liqihang #1
    老师,代码和错误在上面贴出了。我找不到哪里错了
    2018-04-23 16:47:28
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
从网页搭建入门Java Web2018版
  • 参与学习           人
  • 提交作业       1088    份
  • 解答问题       10204    个

如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师