出现404错误
来源:2-12 自由编程
阿硕A
2020-04-01 21:01:20
package com.imooc.month;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
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 MonthServlet
*/
@WebServlet("/MonthServlet")
public class MonthServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public MonthServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<String> list=new ArrayList<String>();
list.add("January");
list.add("February");
list.add("March");
list.add("April");
list.add("May");
request.setAttribute("months", list);
request.getRequestDispatcher("/month.jsp").forward(request, response);
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:forEach items="${requestScope.months }" var="c" varStatus="idx">
<h1>${idx.index+1 }-----${c}</h1>
</c:forEach>
</body>
</html>
1回答
阿硕A
提问者
2020-04-01
老师,发现问题了JSP文件创建错误啦
相似问题