SpringBoot+jsp项目启动出现404的解决方法
这篇文章主要介绍了SpringBoot+jsp项目启动出现404的解决方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧通过maven创建springboot项目启动出现404
application.properties配置
spring.mvc.view.prefix=/web-inf/jsp/
spring.mvc.view.suffix=.jsp
项目结构
控制器方法
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添加依赖
<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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持CodeAE代码之家。
原文链接:https://segmentfault.com/a/1190000018346932
http://www.zzvips.com/article/177120.html
页:
[1]