我的第一次发帖!所以,我目前正在学校创建一个带有艺术家,专辑和曲目的sqlite数据库的java web项目 . 我正试图将所有艺术家列入网页 . 问题是我不断收到404错误 . 我的jsp文件在我的老师的指导下在WebContent / WEB-INF / views中 . 另外我认为我的servlet有问题 . 这是我的servlet:

package javaweb.part1.control;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import levykauppa.Artist;
import levykauppa.ArtistDAO;

@WebServlet("/artist")
public class ArtistServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

private ArtistDAO artistDao = new ArtistDAO();

protected void doGet(HttpServletRequest request, HttpServletResponse response)

    throws ServletException, IOException {

    List<Artist> artists = null;

    try {
        artists = artistDao.findAllArtists();
    } catch (SQLException e) {
        e.printStackTrace();
    }
request.setAttribute("artist", artists);
RequestDispatcher dispatcher = 
request.getRequestDispatcher("levykauppa/WebContent/WEB- 
INF/views/artistlist.jsp");
    dispatcher.include(request, response);

}
}

这是我的jsp文件:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>artist</title>
</head>
<body>
<c:forEach items="${ artists }" var="artist">
<c:out value="${ artist.getName() }" />
</c:forEach>
</body>
</html>