【发布时间】:2018-09-06 05:38:17
【问题描述】:
我尝试使用 servlet 和 JSP 开始我的新项目,但我被困在了第一步。我无法使用 servlet 从一个 html 转发到另一个 html。可能是什么问题?
索引.html:
<body>
<form action="/servlets/HomeServlet" method="get">
<label>Username</label> <input type="text" name="username" id="username"><br />
<label>Password</label> <input type="password" name="password" id="password"><br />
<input type="submit" value="Submit">
</form>
</body>
</html>
Sevlet:
public HomeServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/html/home.html").forwad(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
这是文件夹结构:
提前谢谢你!
【问题讨论】:
-
您的
Servlet可以访问吗?
标签: java html jsp servlets http-status-code-404