【发布时间】:2021-01-13 03:26:13
【问题描述】:
这是我的控制器,应该打开索引页
@Controller
public class index {
@RequestMapping("/index")
public String index() {
return "index";
}
}
html页面太长我不会显示
这是我的 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zetcode</groupId>
<artifactId>cinemaweb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>cinemaweb</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
这些是项目目录
当我运行我的项目浏览器时,显示“HTTP 状态 404 – 未找到”,我阅读了其他帖子,但我没有找到解决方法,请帮帮我
我尝试使用这 2 个链接 http://localhost:8080/cinemaweb 或 http://localhost:8080/index
【问题讨论】:
-
这个post 对你有帮助。请阅读编辑部分。
-
能否分享 application.properties 文件,或者是否设置了
server.servlet.context-path的值 -
我的 application.properties 文件为空
标签: java spring-boot pom.xml