Thymeleaf 无法查看除一页之外的任何内容
我所能做的就是查看index.html,但是当我尝试浏览adminLogin时,我看到的只是:
白标错误页面 此应用程序没有 /error 的显式映射,因此您将其视为后备。 出现意外错误(类型=未找到,状态=404)。
这是PortfolioApplication:
@SpringBootApplication
public class PortfolioApplication {
public static void main(String[] args) {
SpringApplication.run(PortfolioApplication.class, args);
}
@GetMapping("/")
public String getMainPage() {
return "index.html";
}
@GetMapping("/adminLogin")
public String getAboutPage() {
return "adminLogin.html";
}
}
当我尝试从index.html调用另一个页面时,没有任何反应:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hotel_Management_java_project</title>
<link rel="stylesheet" href="css/home.css">
</head>
<body>
<div class="home" id="home">
<nav>
<div class="logo">
<a href="#">
<h2>TourAgency</h2>
</a>
</div>
<div class="header_content">
<ul>
<li><a href="#home">Главная</a></li>
<div class="login">
<button class="loginbtn" id="loginbtn">Вход</button>
<div class="Login_content">
<a th:href="@{/adminLogin}">Вход для админа</a>
<a th:href="@{/employeelogin}">Вход для работника</a>
<a th:href="@{/userlogin}">Вход для пользователя</a>
</div>
</div>
</ul>
</div>
</nav>
</body>
</html>
UserController:
@RestController
@RequestMapping("/users")
public class UserController {
@Autowired
private UserRepository urepo;
@RequestMapping("/")
public String index() {
return "index";
}
@RequestMapping("/userlogin")
public String index1(Model model) {
model.addAttribute("user", new User());
return "userlogin";
}
我试图将@Controller更改为@RestController,将我的主类放在上面等等,但我没有结果
All I can is viewing index.html, but when I am trying to surf to adminLogin for example all i see is:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Not Found, status=404).
here is PortfolioApplication:
@SpringBootApplication
public class PortfolioApplication {
public static void main(String[] args) {
SpringApplication.run(PortfolioApplication.class, args);
}
@GetMapping("/")
public String getMainPage() {
return "index.html";
}
@GetMapping("/adminLogin")
public String getAboutPage() {
return "adminLogin.html";
}
}
when i am trying to call another pages from index.html nothing happens:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hotel_Management_java_project</title>
<link rel="stylesheet" href="css/home.css">
</head>
<body>
<div class="home" id="home">
<nav>
<div class="logo">
<a href="#">
<h2>TourAgency</h2>
</a>
</div>
<div class="header_content">
<ul>
<li><a href="#home">Главная</a></li>
<div class="login">
<button class="loginbtn" id="loginbtn">Вход</button>
<div class="Login_content">
<a th:href="@{/adminLogin}">Вход для админа</a>
<a th:href="@{/employeelogin}">Вход для работника</a>
<a th:href="@{/userlogin}">Вход для пользователя</a>
</div>
</div>
</ul>
</div>
</nav>
</body>
</html>
UserController:
@RestController
@RequestMapping("/users")
public class UserController {
@Autowired
private UserRepository urepo;
@RequestMapping("/")
public String index() {
return "index";
}
@RequestMapping("/userlogin")
public String index1(Model model) {
model.addAttribute("user", new User());
return "userlogin";
}
I was trying change @Controller to @RestController, putting my main class to up and so on, but i've got no result
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论