对于 Servlet使用注解后网页无法找到

 对于 Servlet使用注解后网页无法找到

Servlet3.0相较于Servlet2.5: 目前快捷开发,主流使用注解技术
3.0注解简化的javaweb代码开发,可以省略web.xml配置文件 
支持异步处理(多线程技术) 
支持可插性特性(书写的代码编译后生成的class文件可以直接部署到其他项目的,自动加载执行)

将:

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 java.io.IOException;

@WebServlet(name = "/ServletWebDome")
public class ServletWebDome extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("-----Hello four servlet-----");
    }
}

改为:

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 java.io.IOException;

@WebServlet("/ServletWebDome")
public class ServletWebDome extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("-----Hello four servlet-----");
    }
}
就OK了;

你可能感兴趣的:(对于 Servlet使用注解后网页无法找到)