通过maven创建springboot项目启动出现404
application.properties 配置
|
1 2 |
spring.mvc.view.prefix=/web-inf/jsp/ spring.mvc.view.suffix=.jsp |
项目结构
控制器方法
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
package com.example.demo.controller;
import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping;
@controller public class indexcontroller {
@requestmapping ( "/" ) public string index() { return "index" ; } } |
启动项目访问 localhost:8080 ,出现 404
whitelabel error page
this application has no explicit mapping for /error, so you are seeing this as a fallback.
thu feb 28 22:59:29 cst 2019
there was an unexpected error (type=not found, status=404).
no message available
解决方法
pom.xml 添加依赖
|
1 2 3 4 5 6 7 8 |
<dependency> <groupid>org.apache.tomcat.embed</groupid> <artifactid>tomcat-embed-jasper</artifactid> </dependency> <dependency> <groupid>javax.servlet</groupid> <artifactid>jstl</artifactid> </dependency> |
clean 并刷新 maven
重启并访问 localhost:8080
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
原文链接:https://segmentfault测试数据/a/1190000018346932
查看更多关于SpringBoot+jsp项目启动出现404的解决方法的详细内容...