老师帮忙看看,谢谢
来源:2-12 自由编程
ByteDancer07
2020-02-22 10:41:59
<%@ 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> <html> <head> <meta charset="utf-8"> <title>practice</title> </head> <body> <c:forEach var="p" items="${month}" varStatus="idx"> ${idx.index+1} ——${p}</br> </c:forEach> </body> </html>
Servlet页面
package com.kai.el; import java.io.IOException; import java.util.HashSet; import java.util.Set; 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 Month */ @WebServlet("/month") public class Month extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public Month() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub Set<String> month = new HashSet<String>(); //January、February、March、April、May month.add("January"); month.add("February"); month.add("March"); month.add("April"); month.add("May"); request.setAttribute("month",month); request.getRequestDispatcher("/month.jsp").forward(request, response); } }
1回答
同学完成的很棒,加油,祝学习愉快~
相似问题
回答 1
回答 1
回答 1
回答 1
回答 1