[英]Facing a problem that I can't reach my other .html file
I am new with spring framework and I'm want to use also thymeleaf later. 我是spring框架的新手,以后也想使用thymeleaf。 However, right now I just want to create a basic page where I can stright jump from one tab to another. 但是,现在,我只想创建一个基本页面,在其中可以直接从一个选项卡跳转到另一个选项卡。 When I start my program I can stay in 'home' page, but if I want to open other tab from nav I'm receiving an error. 当我启动程序时,我可以停留在“主页”页面,但是如果我想从导航中打开其他选项卡,则会收到错误消息。 As I understand problem with mapping, but can't realize where's the problem. 据我了解映射问题,但无法意识到问题出在哪里。
Error: 错误:
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Whitelabel Error Page此应用程序没有针对/ error的显式映射,因此您将其视为后备。
Code from Controller: 来自控制器的代码:
package com.project.project.ui.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class WelcomeController {
@RequestMapping("/home")
public String welcome() {
return "index";
}
@RequestMapping(value = "/aphoto", method = RequestMethod.GET)
public String add() {
return "prideti";
}
}
Code from index.html 来自index.html的代码
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Galerija</title>
</head>
<body>
<!-- Navigacija -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="">Galerija</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="prideti.html">Prideti nauja nuotrauka <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Perziureti nuotrauku galerija <span class="sr-only">(current)</span></a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Ieskoti" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Ieskoti</button>
</form>
</div>
</nav>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
And here's my page where I want to get: 这是我要获取的页面:
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Galerija</title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.
Error means, you don't have html files as per controller's mapping or you did not place them on right location in project. 错误的意思是,根据控制器的映射,您没有html文件,或者没有将它们放在项目中的正确位置。
If you're using SpringBoot, you need to create index.html
and prideti.html
on path ApplicationRoot/src/main/resources/templates/
. 如果您使用的是SpringBoot,则需要在路径ApplicationRoot/src/main/resources/templates/
上创建index.html
和prideti.html
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.