java - HTTP 状态 404。描述请求的资源不可用

标签 java eclipse tomcat

<分区>

我这里有一个页面。当我点击提交按钮时,我得到 404 页面:

HTTP Status 404 - /Email/EmailGet


type Status report

message /Email/EmailGet

description The requested resource is not available.


Apache Tomcat/7.0.47

代码:

    <%@ 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>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <form action="EmailGet" method="GET">
        Email: <input type="text" name="email"> <br> Password: <input
            type="password" name="password"> <br> <input
            type="submit" value="Submit">
    </form>
</body>
</html>

这是 EmailGet 代码:

package email;

import java.io.IOException;

import javax.mail.Session;
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 javax.servlet.http.HttpSession;

/**
 * Servlet implementation class Controller
 */
@WebServlet("/EmailGet")
public class EmailGet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public EmailGet() {
        super();
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // Gets the entered email and password

        String username = request.getParameter("email");
        String password = request.getParameter("password");

        //Creates the session and sets the session attributes

        HttpSession session = request.getSession();
        session.setAttribute("username", username);
        session.setAttribute("password", password);

        RequestDispatcher dispatcher;

        //Calls the setCredentials method to check if entered credentials are valid

        boolean result = SendSMTPMail.setCredentials(username, password);

        //if valid, forwards to send page
        if (result == true) {
            dispatcher = request.getRequestDispatcher("send.jsp");
            dispatcher.forward(request, response);      
        }

        //if not valid, forwards to index page with error message displayed
        else {
            dispatcher = request.getRequestDispatcher("indexerror.jsp");
            dispatcher.forward(request, response);      
        }

    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }


}

有什么想法吗?它曾经可以很好地转发页面,但现在似乎无法正常工作。

每个 jsp 页面单独运行良好,只是转发不工作。

最佳答案

看来。 . .请求的页面不存在。我不知道你的文件名,所以我只能猜测你在某处有错字,尝试检查你的 url 栏并检查这是否真的是你想要的 url。

关于java - HTTP 状态 404。描述请求的资源不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27387260/

相关文章:

java - 如何使用 OSGI 打包和使用现有的 Java 库

java - Java 中的字符串池的行为是否类似于 LRU 缓存?

java - 实现用户登录,JDBC 交易问题

java - WindowBuilder 相当于 IntelliJ?

java - 尝试使用 HTTPPOST 时出现与 doInBackground 相关的异步错误

java - 无法使用 URL 连接到 Tomcat 服务器

java - 如何获取两个字符之间出现的所有子字符串?

java - 如何在jsf中使用 session 过滤器作为登录表单

eclipse + tomcat 服务器站点错误

macos - 访问 Tomcat 目录时出现问题