Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 404未找到-在Google AppEngine上部署后,在此服务器上未找到请求的URL/hello servlet_Java_Google App Engine_Servlets - Fatal编程技术网

Java 404未找到-在Google AppEngine上部署后,在此服务器上未找到请求的URL/hello servlet

Java 404未找到-在Google AppEngine上部署后,在此服务器上未找到请求的URL/hello servlet,java,google-app-engine,servlets,Java,Google App Engine,Servlets,我正在尝试使用应用程序引擎创建我的第一个web应用程序。当我使用本地服务器时,一切正常,但在部署之后,当我尝试单击“Hello Servlet”链接到另一个页面时,我得到一个404 not found错误 我试着寻找这个问题,但没有成功。谢谢你的帮助 web.xml文件: <?xml version="1.0" encoding="utf-8"?> <appengine-web-app xmlns="http://appengi

我正在尝试使用应用程序引擎创建我的第一个web应用程序。当我使用本地服务器时,一切正常,但在部署之后,当我尝试单击“Hello Servlet”链接到另一个页面时,我得到一个404 not found错误

我试着寻找这个问题,但没有成功。谢谢你的帮助

web.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>progrweb-project</application>
  <threadsafe>true</threadsafe>
  <runtime>java8</runtime>
</appengine-web-app>

HelloServlet.java:

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello World!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}

@WebServlet(name=“helloServlet”,value=“/hello servlet”)
公共类HelloServlet扩展了HttpServlet{
私有字符串消息;
公共void init(){
message=“你好,世界!”;
}
public void doGet(HttpServletRequest请求、HttpServletResponse响应)引发IOException{
response.setContentType(“text/html”);
//你好
PrintWriter out=response.getWriter();
out.println(“”);
out.println(“+message+”);
out.println(“”);
}
公共空间销毁(){
}
}
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
    <head>
        <title>JSP - Hello World</title>
    </head>
    <body>
        <h1><%= "Hello World!" %></h1>
        <a href="hello-servlet">Hello Servlet</a>
    </body>
</html>
@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello World!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}