【发布时间】:2018-03-21 17:44:25
【问题描述】:
我已经开始使用 spring boot 并尝试创建这个基本程序 但它给出了白色错误页面:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Mar 21 23:06:15 IST 2018
There was an unexpected error (type=Not Found, status=404).
No message available
这里是 pom.xml 文件的依赖部分
<dependencies>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
index.jsp:
<!DOCTYPE html>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html lang="en">
<head></head>
<body>
Hello User....
</body>
</html>
Application.properties 文件:
spring.mvc.view.prefix: /WEB-INF/views/
spring.mvc.view.suffix: .jsp
以下是控制器类:
package com.whiteboard.banking;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/")
public String index(){
return "index";
}
}
我尝试在 index 方法中记录消息,它正在记录,这意味着该方法被调用但 index.jsp 没有呈现。
谁能告诉我错误的原因?
【问题讨论】:
标签: java spring jsp spring-boot