• 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");
        }
    
    }
  • 相关阅读:
    chrome中打开 swf下载的问题
    爱对人比爱上人更重要
    ActiveMQ集群
    ActiveMQ相关API
    ActiveMQ持久化
    ActiveMQ处理模式
    ActiveMQ
    JMS与消息队列
    微服务设计、拆分原则
    web常用服务架构
  • 原文地址:https://www.cnblogs.com/mm163/p/10761497.html
Copyright © 2020-2023  润新知