尝试从JSP表单调用servlet时出现404错误

时间:2017-08-23 15:51:13

标签: java eclipse jsp servlets http-status-code-404

我试图使用表单操作从jsp调用servlet,但是当我提交表单时,会显示404错误。我正在使用Dynamic Web Module 3.0并创建了新的servlet - > eclipse Oxygen的新servlet选项。

Here is the image of my codes

Here is the image of my codes

Here is the image of my codes

Here is the image of my codes

我用过

@WebServlet("/UserLogin")
public class UserLogin extends HttpServlet {
    ......
    ...
}

声明我的servlet。 servelet位于packageFiles包下。

来自jsp文件的代码在这里

在eclipse中我可以清楚地看到eclipse自动映射servlet。

<form class="w3-container" method="get" action="UserLogin">
</form>

并且还使用了

action="UserLogin"
action="/UserLogin"
action="/Exam/UserLogin"

此处考试是我的项目名称。

1 个答案:

答案 0 :(得分:0)

我遇到过这样的问题,尝试在默认包中复制servlet文件,你不会得到404.