找不到Spring Boot Jsp文件

时间:2018-11-14 04:27:23

标签: java spring spring-mvc jsp spring-boot

enter image description here

Spring Boot无法在应用程序中找到jsp文件。我不知道为什么它不能在给定的路径中找到jsp文件。你能让我知道如何解决吗

SpringBootHelloWorldApplication.java

if [MSName] == "fm + / *"

WelcomeController.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
    @SpringBootApplication
    public class SpringBootHelloWorldApplication  {

        public static void main(String[] args) {
            SpringApplication.run(SpringBootHelloWorldApplication.class, args);
        }
    }

application.properties

@Controller
public class WelcomeController {

    @RequestMapping("/hello")
    public String getHello(Model model){        
        model.addAttribute("message", "welcome to the jsp page");
        return "welcome";
    }
}

welcome.jsp

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

pom.xml

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html lang="en">

<body>Message: ${message}
</body>
</html>

1 个答案:

答案 0 :(得分:1)

您在主类上缺少@SpringBootApplication注释。

这是一个有效的示例:Spring-Boot-Jsp-Demo