继上面第二个springboot项目后,今晚应朋友需求帮忙写个抽奖程序,想着就用springboot+servlet去发布一个服务给前端直接调用或者后端直接调用。
下面来介绍一下:
1、不错,依然需要一个Application的启动springboot的入口
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* Created by LK on 2016/5/7.
*/
@SpringBootApplication
@ServletComponentScan
public class SpringBootServletSampleApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootServletSampleApplication.class,args);
}
}
特别的注意一下,是通过使用注解注册Servlet
@ServletComponentScan
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import