我正在嘗試使用 Springboot(JPA、H2)和 Thymeleaf 構(gòu)建我的第一個 Web 應(yīng)用程序。entities/我的目標(biāo)是通過控制器( )獲取/修改/刪除存儲到數(shù)據(jù)庫( )中的數(shù)據(jù)controllers/。但是,家鄉(xiāng)路線不起作用。你能告訴我并解釋我做錯了什么嗎?我忘了配置什么?感謝幫助!錯誤網(wǎng)址:localhost:8082/Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback.Fri Mar 08 14:22:21 CET 2019There was an unexpected error (type=Not Found, status=404).No message available索引控制器@RestController@RequestMapping("/")public class IndexController { @GetMapping(value = "/") public ModelAndView getHome(){ ModelAndView mv = new ModelAndView(); mv.setViewName("index"); return mv; }}索引.html<!DOCTYPE html><html xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"> <title>Home</title> <link rel="stylesheet" href="../static/css/bootstrap.min.css"></head><body> <p>Test</p></body></html>文件夾projetname/|__src/ |__main/ |__java/ |__projectname/ | |__controllers/ | | |__IndexController.java | |__entities/ | |__repositories/ | |__App.java |__resources/ |__static/ | |__css/ | |__js/ |__templates/ | |__index.html |__data.sql |__application.properties
2 回答

慕妹3242003
TA貢獻(xiàn)1824條經(jīng)驗 獲得超6個贊

SMILET
TA貢獻(xiàn)1796條經(jīng)驗 獲得超4個贊
當(dāng)應(yīng)用程序啟動時,查看它的日志并找到類似的映射
2019-03-08 17:52:24.864 INFO 9592 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting]}" onto public hello.Greeting hello.GreetingController.greeting(java.lang.String)
這意味著您可以使用 /greeting 調(diào)用 URL,并將其映射到對應(yīng)的控制器
404 錯誤表示您調(diào)用的 URL 未映射
添加回答
舉報
0/150
提交
取消