如何解决Spring Core:无法创建基本请求我缺少什么?
以前,我是使用Spring Boot构建项目的,对我来说一切都很好且自动化。现在,我尝试学习一些Spring核心知识,并且我坚持了几天的基本工作却无法找到项目中的问题。我正在尝试创建一个始终以找不到的404结尾的基本请求。
@Controller
public class Test {
@GetMapping("/home")
public String doStuff(){
return "index";
}
}
index.jsp
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
pom.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.8.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.7.RELEASE</version>
</dependency>
</dependencies>
当我在本地的tomcat上部署战争并转到http://localhost:8080/home
时,我总是看不到我所缺少的内容。我总是得到404。我的spring core软件包结构是否错误?我有:
src>java>com>example>Test
用于控制器类,
src>main>webapp>index.jsp
查看。我什至在主文件夹中创建了一个resources文件夹,并在其中添加了index.jsp,但这是同样的问题。 这就是我所拥有的一切,使用Spring Boot可以正常工作,是否缺少ViewResolver的配置?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。