java - 访问控制器映射的 URL 差异
问题描述
我正在尝试学习Spring Framework
,Spring MVC
并且Spring Boot REST
在创建一个虚拟项目时,我注意到浏览器中Tomcat
响应您的方式的差异如下URL
弹簧靴
http://localhost:8080/
Redirects to the Controller that is mapped to "/"
http://localhost:8080/springbootrestapp
where "springbootrestapp" is the project name, it gives HTTP 404 resource not found error
春季MVC
http://localhost:8080/
Opens the Tomcat Home page
http://localhost:8080/springmvc
where "springmvc" is the project name, it redirects to the Controller that is mapped to "/"
我的疑问是,为什么Spring Boot
只是输入localhost:8080
重定向到controller
映射到"/"
的情况,而在Spring MVC
(没有 Spring Boot 配置)的情况下,它需要http://localhost:8080/<projectname>/
重定向到controller
映射到"/"
?
解决方案
我遇到了同样的问题在我的情况下,在运行我的 Spring-MVC 应用程序之前,我启动了我没有停止的 tomcat 服务器,所以每当我访问 localhost:8080/ 时,它都会将我重定向到 Tomcat 客户端。
推荐阅读
- c - 为什么我的右移运算符在逻辑上而不是在 c 中以算术方式运行?
- amazon-web-services - Amazon 为 EKS VPC 设置建议的 Cloudformation 模板直接与其建议相矛盾。是否存在其他模板?
- debugging - 如何在 GDB 中设置断点,但不让断点暂停执行?如果线路被击中,我只想在控制台中收到通知
- excel - VBA中的自动过滤器
- bash - Bash 脚本 - AWS SSM 并行导出变量
- wagtail - 当我复制一个页面时,它的 ParentalManyToManyFields 不会被复制。难道我做错了什么?
- html - 请我试图将我的项目连接到数据库,但出现错误:当前上下文中不存在名称“文本框”
- python - 在类中设置python方法的属性
- c# - NHibernate QueryOver 删除重复项
- javascript - 用javascript中的键检索对象