【Springboot总结】20 使用外置的Servlet容器

嵌入式Servlet容器:应用打成可执行的jar

​     优点:简单、便携;

​     缺点:默认不支持JSP、优化定制比较复杂

外置的Servlet容器:外面安装Tomcat---应用war包的方式打包;

 

使用外置的Servlet容器的步骤

1. 创建war项目

【Springboot总结】20 使用外置的Servlet容器

2. 调整目录

(1) 按键F4 

【Springboot总结】20 使用外置的Servlet容器

【提示】若是没有web模块,点击那个绿色的加号,添加上去就可以了!

 

【Springboot总结】20 使用外置的Servlet容器

 

(2)双击webapp的那个目录

【Springboot总结】20 使用外置的Servlet容器

【提示】默认src/main/webapp 

 

(3)提示是否创建,点击OK!

【Springboot总结】20 使用外置的Servlet容器

点击yes,创建webapp文件夹

 

(4)创建web.xml文件

【Springboot总结】20 使用外置的Servlet容器

 

(5)调整web.xml文件的路径

【Springboot总结】20 使用外置的Servlet容器

(6)点击apply生成webapp文件夹以及相应的web.xml

【Springboot总结】20 使用外置的Servlet容器

(7)

【Springboot总结】20 使用外置的Servlet容器

 

3、IDEA整合tomcat

(1)打开run/Debug Configurations

【Springboot总结】20 使用外置的Servlet容器

 

【Springboot总结】20 使用外置的Servlet容器

(2)点击添加 tomcat server - local

 

【Springboot总结】20 使用外置的Servlet容器

 

【Springboot总结】20 使用外置的Servlet容器

 

(3)配置tomcat server 

【Springboot总结】20 使用外置的Servlet容器

 

 

【Springboot总结】20 使用外置的Servlet容器

 

【Springboot总结】20 使用外置的Servlet容器

 

【Springboot总结】20 使用外置的Servlet容器

至此整合完毕!

 

4. 启动服务器

【Springboot总结】20 使用外置的Servlet容器

 

启动服务器之后,服务器上的springboot项目就启动了!

 

5. 测试

(1)前端界面 hello.jsp

【Springboot总结】20 使用外置的Servlet容器

 (2)success.jsp

【Springboot总结】20 使用外置的Servlet容器

(3)在application.properties配置视图解析器的前后缀

【Springboot总结】20 使用外置的Servlet容器

(4)Controller

【Springboot总结】20 使用外置的Servlet容器