server
1.编写一个类去继承httpServlet类
2.根据业务需要重写doget或者dopost方法
3.到web.xml配置servlet程序访问地址
实际业务需求中新建文件
重写doget和dopost
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| package com.atguigu.servlet;
import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException;
public class HelloServlet1 extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doGet(req, resp); }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doPost(req, resp); } }
|
写好以后去配置访问地址‘
直接newservlet
interface servlet
实现接口↑
class cenericservlet
继承↑
class httpservlet
继承↑
自定义的servlet程序