How to configure spring boot through annotations in order to have something similar to <jsp-config> in web.xml?

简介: JSP file not rendering in Spring Boot web application You will need not one but two dependencies (jasper and jstl) in your pom.

 

JSP file not rendering in Spring Boot web application

You will need not one but two dependencies (jasper and jstl) in your pom.xml for this to work.

   <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <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>
</dependencies>

 

You just made my day! This helped me - even though my issue was slightly different - Spring wasn't evenfinding my .jsp files in /src/main/resources/webapp/WEB-INF/pages. Thank you so much! 

http://stackoverflow.com/questions/20602010/jsp-file-not-rendering-in-spring-boot-web-application

 

How to configure spring boot through annotations in order to have something similar to <jsp-config> in web.xml?

How to configure spring boot through annotations in order to have something similar to in web.xml?

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <url-pattern>*.jspf</url-pattern>
        <page-encoding>UTF-8</page-encoding>
        <scripting-invalid>false</scripting-invalid>
        <include-prelude>/WEB-INF/jsp/base.jspf</include-prelude>
        <trim-directive-whitespaces>true</trim-directive-whitespaces>
        <default-content-type>text/html</default-content-type>
    </jsp-property-group>
</jsp-config>

 

I think Dave gave a pretty straight forward answer - that is - there is no Java API defined by the Servlet spec for configuring JSPs and if you must use it with Spring Boot you just need to use web.xml which Spring Boot perfectly supports. This sounds pretty clear to me.

Cheers.

 

http://stackoverflow.com/questions/24293901/how-to-configure-spring-boot-through-annotations-in-order-to-have-something-simi

 

相关文章
|
7天前
|
JSON Java fastjson
Spring Boot 底层级探索系列 04 - Web 开发(2)
Spring Boot 底层级探索系列 04 - Web 开发(2)
16 0
|
22天前
|
前端开发 安全 Java
使用Java Web框架:Spring MVC的全面指南
【4月更文挑战第3天】Spring MVC是Spring框架的一部分,用于构建高效、模块化的Web应用。它基于MVC模式,支持多种视图技术。核心概念包括DispatcherServlet(前端控制器)、HandlerMapping(请求映射)、Controller(处理请求)、ViewResolver(视图解析)和ModelAndView(模型和视图容器)。开发流程涉及配置DispatcherServlet、定义Controller、创建View、处理数据、绑定模型和异常处理。
使用Java Web框架:Spring MVC的全面指南
|
1月前
|
网络安全
ssh(Spring+Spring mvc+hibernate)——applicationContext.xml
ssh(Spring+Spring mvc+hibernate)——applicationContext.xml
7 0
|
1月前
|
存储 搜索推荐 Java
springboot280基于WEB的旅游推荐系统设计与实现
springboot280基于WEB的旅游推荐系统设计与实现
|
1月前
|
搜索推荐 Java 数据库
springboot基于Web的社区医院管理服务系统
springboot基于Web的社区医院管理服务系统
|
2月前
|
JSON IDE Java
创建一个简单的Spring Boot Web项目
创建一个简单的Spring Boot Web项目
52 1
|
2月前
|
Java Maven 开发者
深入剖析Spring Boot在Java Web开发中的优势与应用
深入剖析Spring Boot在Java Web开发中的优势与应用
|
2月前
|
Java API 开发者
Spring框架在Java Web开发中的最佳实践
Spring框架在Java Web开发中的最佳实践
|
2月前
|
前端开发 Java 应用服务中间件
【JavaEE进阶】 初识Spring Web MVC
【JavaEE进阶】 初识Spring Web MVC
|
2月前
|
XML Java 测试技术
【SpringBoot】基于 Maven 的 pom.xml 配置详解
【SpringBoot】基于 Maven 的 pom.xml 配置详解
224 0
【SpringBoot】基于 Maven 的 pom.xml 配置详解