SpringBoot+jsp項(xiàng)目啟動(dòng)出現(xiàn)404的解決方法
通過maven創(chuàng)建springboot項(xiàng)目啟動(dòng)出現(xiàn)404
application.properties配置
spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp
項(xiàng)目結(jié)構(gòu)

控制器方法
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";
}
}
啟動(dòng)項(xiàng)目訪問localhost:8080,出現(xiàn)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

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
一文掌握J(rèn)ava開發(fā)工具M(jìn)aven(簡單上手)
掌握maven的相關(guān)知識(shí)是Java開發(fā)必備的技能,今天通過本文從入門安裝開始,逐步深入講解maven的相關(guān)知識(shí),包括maven的安裝到簡單上手maven項(xiàng)目開發(fā),感興趣的朋友跟隨小編一起看看吧2021-06-06
Java如何獲取resources下的文件路徑和創(chuàng)建臨時(shí)文件
這篇文章主要介紹了Java如何獲取resources下的文件路徑和創(chuàng)建臨時(shí)文件,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12
Java文件斷點(diǎn)續(xù)傳實(shí)現(xiàn)原理解析
這篇文章主要介紹了Java文件斷點(diǎn)續(xù)傳實(shí)現(xiàn)原理解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-05-05
Java定時(shí)任務(wù)的三種實(shí)現(xiàn)方法
在應(yīng)用里經(jīng)常都有用到在后臺(tái)跑定時(shí)任務(wù)的需求。舉個(gè)例子,比如需要在服務(wù)后臺(tái)跑一個(gè)定時(shí)任務(wù)來進(jìn)行垃圾回收2014-04-04
windows下使用 intellij idea 編譯 kafka 源碼環(huán)境
這篇文章主要介紹了使用 intellij idea 編譯 kafka 源碼的環(huán)境,本文是基于windows下做的項(xiàng)目演示,需要的朋友可以參考下2021-10-10

