servlet与springboot

@WebServlet(name = "httpServletDemo",
        urlPatterns = "/httpServletDemo",
        initParams = {
        @WebInitParam(name = "name", value = "username"),
        @WebInitParam(name = "mobile", value = "1232423434")
})
@Controller
public class HttpServletDemo extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = getInitParameter("name");
        String mobile = getInitParameter("mobile");
        System.out.println("name:"+name+"; mobile:"+mobile);
        resp.getWriter().print("this is a demo");
        resp.setStatus(200);
    }

    @Override
    protected long getLastModified(HttpServletRequest req) {
        return super.getLastModified(req);
    }

    @Override
    protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doHead(req, resp);
    }

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

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPut(req, resp);
    }

    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doDelete(req, resp);
    }

    @Override
    protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doOptions(req, resp);
    }

    @Override
    protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doTrace(req, resp);
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.service(req, resp);
    }

    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        String name = getInitParameter("name");
        String mobile = getInitParameter("mobile");
        System.out.println("name:"+name+"; mobile:"+mobile);
        super.service(req, res);
    }
}

spring boot 启动类

创新互联是一家专注于成都网站建设、网站建设与策划设计,三门峡网站建设哪家好?创新互联做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:三门峡等地区。三门峡做网站价格咨询:028-86922220

@SpringBootApplication
@EnableEurekaClient
@ServletComponentScan(basePackages = {"com.example.demo.filter","com.example.demo.interceptor","com.example.demo.servlet"})
public class SpringWebDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringWebDemoApplication.class, args);
    }
}

网站题目:servlet与springboot
转载注明:http://bzwzjz.com/article/jpjoig.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 盐亭网站设计 教育网站设计方案 成都网站设计 高端网站设计 专业网站设计 成都网站设计 企业手机网站建设 成都网站设计 成都网站制作 重庆网站制作 LED网站设计方案 阿坝网站设计 成都响应式网站建设公司 定制级高端网站建设 外贸网站建设 网站制作 网站设计 高端网站建设 温江网站设计 成都网站建设公司 高端网站设计 企业网站建设