Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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 请求的资源不适用于servlet 3.0和tomcat 7.0_Java - Fatal编程技术网

Java 请求的资源不适用于servlet 3.0和tomcat 7.0

Java 请求的资源不适用于servlet 3.0和tomcat 7.0,java,Java,我的动态web模块版本是3.0,tomcat我的tomcat版本是7.0 我不知道为什么当我导航到页面localhost:8080/SimpleProject时,它看不到我的servlet XD 当我导航到localhost:8080/SimpleProject/firstservlet时,我收到一条错误消息,提示请求的资源不可用 这是我的servlet: @WebServlet(description = "the first servlet", urlPatterns = { "/first

我的动态web模块版本是3.0,tomcat我的tomcat版本是
7.0

我不知道为什么当我导航到页面localhost:8080/SimpleProject时,它看不到我的servlet XD

当我导航到localhost:8080/SimpleProject/firstservlet时,我收到一条错误消息,提示
请求的资源不可用

这是我的servlet:

@WebServlet(description = "the first servlet", urlPatterns = { "/firstservlet" })
public class FirstServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//   response.setContentType("text/html");
    PrintWriter writer = response.getWriter();
    writer.println("<h1>Why can't See<h1>");
}
@WebServlet(description=“第一个servlet”,urlPatterns={”/firstservlet})
公共类FirstServlet扩展了HttpServlet{
私有静态最终长serialVersionUID=1L;
受保护的void doGet(HttpServletRequest请求,HttpServletResponse响应)抛出ServletException,IOException{
//response.setContentType(“text/html”);
PrintWriter=response.getWriter();
println(“为什么看不见”);
}
我没有在web.xml上做任何事情,因为我知道在3.0版本中,url映射在servlet中

这是我的文件安排:)

您是否检查了日志文件,以查看在加载/执行servlet FirstServlet时是否引发了异常


您是否检查了war文件的内容,以确保其包装正确且servlet类在其中(您可以像打开zip文件一样打开war文件)。

您的上下文(根路径)是您的war名称(以“.war”结尾)除非您在context.xml文件中专门将其设置为其他内容。您可以共享您的web.xml吗?@shadowcroper我已经这样做了。但请求的资源仍然不可用available@F.H.当你把一个html文件放在war的根目录中时,你能用浏览器点击它吗?
http://localhost:8080/SimpleProject/index.html
用于instance?@暗影爬行者是的,我做到了。。。