问题描述
我有一个类似我的应用程序索引的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 configurationApplication.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具有在处理JSP方面的一些限制.准确地说,它建议将JSP保留在src/main/webapp
文件夹中,并将包装从jar
更改为war
.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!