繁体   English   中英

Spring Boot Web启动器查看位置

[英]Spring Boot Web starter views location

我试图制作一个简单的Spring Boot Web应用程序:

POM:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.0.0.BUILD-SNAPSHOT</version>
    </parent>

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

主要课程:

@ComponentScan(basePackages={"controller"})
@Import(MvcConfig.class)
@EnableAutoConfiguration
public class Application {

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

控制器:

@Controller
@RequestMapping("/home")
public class HomeController {
    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "hello";
    }
    @RequestMapping("/helloView")
    public String helloView(){
        return "homeView";
    }
}

我也得到了src/main

src
   -main
       -resources
            applicaion.properties
       -webapp
            -WEB-INF
                 -jsp
                     -homeView.jsp

在application.properties我得到:

  spring.view.prefix: /WEB-INF/jsp/
  spring.view.suffix: .jsp 

其余的端点/home/hello有效,但另一个无法打开jsp。 在我得到的日志中

Looking up handler method for path /WEB-INF/jsp/homeView.jsp
Did not find handler method for [/WEB-INF/jsp/homeView.jsp]

我应该在哪里放置视图,以便应用程序可以找到它们?

感谢geoand的回答,我补充道

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>  

到了pom并且它起作用了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM