Spring Boot JSP 404

我试图在我的Spring Boot" title="Spring Boot">Spring Boot服务中添加一个jsp页面。我的问题是,每次我尝试转到该页面时,都会显示以下内容:

`Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Apr 21 23:16:00 EEST 2015 There was an unexpected error (type=Not Found, status=404). No message available`

我已经在我的application.properties中添加了前缀和sufix:

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

spring.view.suffix: .jsp

这是我的控制器类:

@Controller

public class MarkerController {

@RequestMapping(value="/map")

public String trafficSpy() {

return "index";

}

}

我的应用程序类:

@SpringBootApplication

public class Application extends SpringBootServletInitializer {

private static Logger logger = Logger.getLogger(Application.class.getName());

public static void main(String[] args) {

logger.info("SPRING VERSION: " + SpringVersion.getVersion());

SpringApplication.run(Application.class, args);

}

}

还有index.jsp:

<!DOCTYPE html>

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

<html lang="en">

<body>

<h1>Hello, World!!!</h1>

<p>JSTL URL: ${url}</p>

</body>

</html>

这是src文件结构:

├── src

│ ├── main

│ │ ├── java

│ │ │ └── com

│ │ │ └── example

│ │ │ └── internetprogramming

│ │ │ └── myserver

│ │ │ └── server

│ │ │ ├── Application.java

│ │ │ ├── config

│ │ │ │ └── DatabaseConfig.java

│ │ │ ├── controller

│ │ │ │ └── MarkerController.java

│ │ │ ├── dao

│ │ │ │ ├── MarkerDaoImplementation.java

│ │ │ │ └── MarkerDaoInterface.java

│ │ │ ├── Marker.java

│ │ │ └── service

│ │ │ ├── MarkerServiceImplementation.java

│ │ │ └── MarkerServiceInterface.java

│ │ ├── resources

│ │ │ └── application.properties

│ │ └── webapp

│ │ └── WEB-INF

│ │ └── jsp

│ │ └── index.jsp

回答:

确保依赖项列表中包含jasper和jstl:

    <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>

以上是 Spring Boot JSP 404 的全部内容, 来源链接: utcz.com/qa/401926.html

回到顶部