> For the complete documentation index, see [llms.txt](https://spring-boot.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spring-boot.shujuwajue.com/webying-yong-kai-fa/mo-ban-yin-qing-jsp.md).

# 4.模板引擎jsp

## 模板引擎jsp

> 注意：因为jsp需要使用外部的tomcat进行运行。
>
> 所以一定要注意tomcat的版本要和jdk的位数相同，还有就是如果你是使用 高版本的spring boot，一定要使用稍微高点的版本 tomcat（比如说我再使用spring boot2.0.3版本写示例，结果运行在tomcat7上各种报错，tomcat8 完美运行），以上是两个坑。
>
> 还有webapp目录设置成resource目录

参考：[Spring Boot 2.0 返回JSP页面实战](https://www.cnblogs.com/xingyunblog/p/8727079.html)

> 注：jsp应该尽量避免使用，原因如下：\
> 1.jsp只能打包为：war格式，不支持jar格式，只能在标准的容器里面跑（tomcat，jetty都可以）\
> 2.内嵌的Jetty目前不支持JSPs\
> 3.Undertow不支持jsps\
> 4.jsp自定义错误页面不能覆盖spring boot 默认的错误页面

## 其他

### 依赖

修改pom.xml,添加如依赖

```markup
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>
```

其他参考：

[spring boot 完整集成jsp。（亲测可用）](https://www.cnblogs.com/mercurys/p/7685102.html)

[Spring Boot实现JSP解析](https://blog.csdn.net/u010857795/article/details/77072912)

[SpringBoot2.0学习(二)-Servlet\&Jsp](https://www.jianshu.com/p/88397a09f153)

[tomcat报错org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method manageApp](https://blog.csdn.net/x631617479/article/details/78764707)

[Intellij Idea 2017创建web项目及tomcat部署实战](https://www.cnblogs.com/shindo/p/7272646.html)
