而是在web.xml servlet映射的解决,我试图用注释到servlet映射到网址如下:与注释的Servlet映射没有得到由谷歌应用程序引擎开发服务器
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "GuestbookServlet", urlPatterns = "/guestbook")
public class GuestbookServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Hello, world");
}
}
而且我也宣布在web.xml中3.0规范的servlet的:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="false">
</web-app>
然而,当我在我的本地环境中运行它返回的响应是404
如果我正m它的工作原理然而,在web.xml中使用servlet。我究竟做错了什么? GAE是否仍然不支持3.0规格?
其值得一提的,这是最近由GAE产品经理之一发表评论 - https://code.google.com/p/googleappengine/issues/detail?id=3091#hc77 – Nick