Springboot整合Servlet简单小测试
@SuppressWarnings(“serial”)解决报黄线访问http://localhost:8080/index.html后台输出@ServletComponentScan能够扫描到项目中的Servlet第二种整合servlet方法:通过创建Bean 来实现访问 GET@WebServlet("/index.html")public class Ind...
·
@SuppressWarnings(“serial”)解决报黄线
访问http://localhost:8080/index.html 后台输出
@ServletComponentScan 能够扫描到项目中的Servlet
第二种整合servlet方法:
通过创建Bean 来实现访问 GET
@WebServlet("/index.html")
public class IndexServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("访问到了我的Get方法");
}
}
bean.addUrlMappings("/index.html");可以放二个位置都能访问
//创建一个bean
@Bean
public ServletRegistrationBean getBean() {
ServletRegistrationBean bean=new ServletRegistrationBean(new IndexServlet(),"/index.html");
// bean.addUrlMappings("/index.html");
return bean;
}
更多推荐
所有评论(0)