小编典典

编辑器中的Eclipse JSP错误

jsp

我在jsp文件中出现错误(在X行上),但这似乎都是正确的。

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

    <form method="GET"
X           action="${pageContext.request.contextPath}/docreatetask">
        <table>
            <tr>
                <td>Task</td>
                <td><input name="task" type="text" /></td>
            </tr>
            <tr>
                <td>Description</td>
                <td><input name="description" type="textarea" /></td>
            </tr>
            <tr>
                <td>Deadline</td>
                <td><input name="description" type= /></td>
            </tr>
            <tr>
                <td></td>
X                   <td><input name="Create new task" type="submit" /></td>
            </tr>
        </table>
    </form>

</body>

**Error 1** javax.servlet.ServletException can not be resolved
**Error 2** javax.servlet.http can not be resolved

会是什么呢?是否在任何地方使用ServletException或javax.servlet.http?


阅读 378

收藏
2020-06-10

共1个答案

小编典典

对于第一个错误(java.servlet.http can not be resolved to a type),您需要将servlet- api.jar文件放入`classpath:

为此,请按照下列步骤操作:

  1. 右键单击该项目。
  2. 单击构建路径->配置构建路径
  3. 在库选项卡中->单击添加外部jar
  4. 选择servlet-api.jar档案

对于第二个错误:( javax.servlet.ServletException can not be resolved):

  1. 右键点击项目
  2. 选择属性选项卡
  3. 选择目标运行时选项卡
  4. 检查您使用的服务器
2020-06-10