Spring Boot中的JSP [英] JSP in Spring Boot

查看:91
本文介绍了Spring Boot中的JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似我的应用程序索引的JSP页面,它位于/resources/jsp/index.jsp 中.我设置了何时调用此页面的特定路由.但是,当我打开localhost时,我得到一个404,因为SpringBoot将 .vm 扩展名放在文件的末尾.
我该如何解决?

I have a JSP page like index of my application, it is located in /resources/jsp/index.jsp. I've set for when a certain route to parth this page is called. But I get a 404 when I open localhost because SpringBoot is putting .vm extension at the end of the file.
How do I fix this?

日志

2015-07-15 08:39:51.226 ERROR 3977 --- [nio-8181-exec-1] org.apache.velocity                      : ResourceManager : unable to find resource '/jsp/index.jsp.vm' in any resource loader.
2015-07-15 08:39:51.290 ERROR 3977 --- [nio-8181-exec-1] org.apache.velocity                      : ResourceManager : unable to find resource 'error.vm' in any resource loader.

索引API

@RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView getIndex() {
        return new ModelAndView("/jsp/index.jsp");
    }

即使我将JSP扩展放入配置中,也会发生这种情况 Application.properties

This happens even I put JSP extension in configuration Application.properties

spring.application.name=VeiculoService

spring.data.mongodb.uri=mongodb://localhost:27017/oknok

spring.data.rest.baseUri=/api

spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.http.gzip.enabled=true

spring.view.suffix= .jsp

management.context-path=/actuator

info.app.name=OKNOK Admin
info.app.description=OKNOK
info.app.version=${project.version}

server.port=${port:8181}
server.servletPath=/

推荐答案

Spring Boot具有

Spring Boot has some limitations in handling JSPs. Precisely, it suggests to keep the JSPs inside the src/main/webapp folder, and change the packaging from jar to war.

这篇关于Spring Boot中的JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆