【发布时间】:2017-12-01 08:26:47
【问题描述】:
我正在尝试使用 Intellij IDEA 运行我的 Spring Boot 项目。
这个项目是 Spring MVC 类型的,意味着它在路径 main/webapp/WEB-INF/jsp 中有 JSP 文件。
我的application.properties 有这些设置:
spring.view.prefix=/WEB-INF/jsp/
spring.view.suffix=.jsp
当我在 Intellij 中将项目作为“Spring Boot 运行配置”运行时,服务器无法识别 JSP 文件的路径。这是我收到的消息:
如果我使用命令spring-boot:run 使用“Maven 运行配置”运行项目,一切正常。
我不知道为什么会这样。项目的代码和设置与每个运行配置相同。
你可以试试这个项目(不是我的项目)来理解我的意思https://github.com/mariuszs/spring-boot-web-jsp-example。
我的项目也是如此。 我应该注意,当项目使用 Spring Boot Run Configuration 运行时,我确实在控制台中看到控制器映射正确。
2017-06-28 08:29:13.906 INFO 10308 --- [ main] o.s.w.s.h.SimpleUrlHandlerMapping : Mapped URL path [/login] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2017-06-28 08:29:13.835 INFO 10308 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET]}" onto public java.lang.String com.intuit.mintbills.controllers.generic.LoginController.getLoginPage()
【问题讨论】:
-
为什么
webapp在main包中? -
为什么不应该在那里? github.com/mariuszs/spring-boot-web-jsp-example/tree/master/src/…github.com/spring-projects/spring-boot/tree/master/…。第二个例子是Spring Boot正式例子
-
我认为您可能需要在 IntelliJ 中将
webapp文件夹标记为“资源”。
标签: java maven jsp intellij-idea spring-boot