• springboot拦截器之自定义原生servlet(二)


    1servlet3.0实现自定义的servlet

    结构:

     2代码

    package com.example.demo.servlet;

    import java.io.IOException;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * 访问地址:http://localhost:8080//v1/test/customs
    * 访问页面的结果:custom servlet
    * @author Administrator
    *
    */
    @WebServlet(name="userServlet",urlPatterns = "/v1/test/customs")
    public class UserServlet extends HttpServlet {

    @Override
    public void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException{
    resp.getWriter().print("custom servlet");
    resp.getWriter().flush();
    resp.getWriter().close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    this.doGet(req, resp);;
    }
    }

  • 相关阅读:
    模板为webpack的目录结构
    实例和内置组件
    微信小程序之富文本解析
    微信小程序获取输入框(input)内容
    for循环的语法和执行顺序
    循环
    选择结构(二)
    选择结构
    算术运算
    变量
  • 原文地址:https://www.cnblogs.com/zhushilai/p/13559431.html
Copyright © 2020-2023  润新知