问题描述
index.jsp 页面报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html dir="ltr" lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>MavenDemo</title>
<meta name="keywords" content="Maven,Java Web" />
<meta name="description" content="">
</head>
<body>
<h2>Hello World!</h2>
</body>
</html>
解决方法
1)右键项目 —> Build Path —> Configure Build Path... —> Java Build Path —> Libraries —> Add Libraries... —> JRE System Library —> Next —> 选择 Workspace default JRE(JDK Version)
—> Finish。
2)继续 Add Libraries... —> Server Runtime —> Next —> 选择 Apache Tomcat v7.0(Apache Tomcat Version) —> Finish —> OK。
3)右键项目 —> Maven —> Update Project... —> 勾选项目 mavenDemo —> OK 即可。