不断获得WhiteLabel错误页面 - Spring启动

时间:2017-06-05 19:56:21

标签: java spring maven jsp spring-mvc

嘿,我在一个简单的弹簧启动应用程序中查看jsp文件时遇到问题。

以下是我的项目文件:

的pom.xml

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

<groupId>com.sample</groupId>
<artifactId>boot-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.3.RELEASE</version>
</parent>

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

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

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>


</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.5.3.RELEASE</version>
        </plugin>
    </plugins>
</build>

HomeController.java

package com.sample;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class HomeController {

    @RequestMapping("/home")
    public String home(){
        return "home";
    }
}

针对home.jsp

<%@ page language="java" contentType="text/html" pageEncoding="UTF-8"%>
<html lang="en">

<head>
    <h1>Title</h1>
</head>

<body>
    <h2>text</h2>
</body>

</html>

application.properties

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

file structure

我发现它可能是application.properties中的文件结构或前缀路径,但仍未找到答案。

1 个答案:

答案 0 :(得分:0)

来自Spring boot文档:

  如果可能的话,应该避免使用JSP,有几种已知的   与嵌入式servlet容器一起使用时的限制。

您可以在此处进一步阅读:

http://docs.spring.io/spring-boot/docs/1.5.3.RELEASE/reference/htmlsingle/#boot-features-spring-mvc-template-engines