1、新建web_maven工程
建工程
web_project——>suportMaven——>generate web.xml——>standard Maven Project
2、pom.xml中添加servelet依赖
javax.servletjavax.servlet-api3.0.1provided
3、开发http接口(继承HTTPServlet类)
packagecom.guoyasoft;importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;publicclassLoginextendsHttpServlet{@OverrideprotectedvoiddoGet(HttpServletRequest req, HttpServletResponse resp)throwsServletException, IOException{ System.out.println("------------login doGet-----------------");super.doGet(req, resp); }@OverrideprotectedvoiddoPost(HttpServletRequest req, HttpServletResponse resp)throwsServletException, IOException{ System.out.println("-------------login doGet-----------------");super.doPost(req, resp); }}
网友评论