zoukankan      html  css  js  c++  java
  • servlet

    1.实现httpservlet

    @WebServlet("/some")
    public class SomeServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.getWriter().print("some Servlet");
        }
    }

    2.

    @SpringBootApplication
    @ServletComponentScan("com.abc.servlet")  // 指定要扫描Servlet的包
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
    }

    ----------------------------------------------------------------------------------------------------------------------------

              2.5

    public class SomeServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.getWriter().print("some Servlet");
        }
    }

    在配置类中写

    @SpringBootApplication
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
        // 基于JavaConfig方式:适用于Servlet2.5+
        // 基于注解方式:适用于Servlet3.0+
        @Bean
        public ServletRegistrationBean<SomeServlet> getServlet() {
            return new ServletRegistrationBean<>(new SomeServlet(), "/some");
        }
    
    }
  • 相关阅读:
    zookeeper安装
    Xmemcached的FAQ和性能调整建议
    memcache命令
    xmemcached的使用
    从硬币游戏学习敏捷开发
    memcached安装
    系统负载能力浅析
    kubernetes1.18安装metrics-server服务
    启动docker run 报错:iptables No chain/target/match by that name
    docker容器内apt更换国内阿里源
  • 原文地址:https://www.cnblogs.com/mm163/p/10761497.html
Copyright © 2011-2022 走看看