简体   繁体   English

遇到我无法访问其他.html文件的问题

[英]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.htmlprideti.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我无法在文件分割程序(Java)中找到正确的解决方案? - Why can't I reach the correct solution in my file splitting program (Java)? 我如何在arraylist上到达对象 - How can I reach my object at arraylist 在 andriod studio 3.2 中面临问题无法运行模拟器我的电脑规格是 2gm ram,甚至无法构建应用程序 - facing problem in andriod studio 3.2 can't run emulator my computer specs are 2gm ram and can not even build app 暴露 SPRING-WS WSDL 的问题,无法通过 url 访问它 - Problem exposing SPRING-WS WSDL, can't reach it with the url jStyleParser无法解析我的html文件 - jStyleParser can't parse my html file 无法到达我的OnClickListener函数中的(最终)按钮 - Can't reach my (final) button inside my OnClickListener function 我的项目找不到 jsp 文件,我认为问题出在 application.properties 文件中,但不知道如何解决 - My project can't find jsp file, I think the problem is in application.properties file, but dont know how to fix it 为什么找不到可以连接到特定主机的接口? - Why can't I find the interface that can reach a specific host? 我如何知道我发送的电子邮件是否到达接收者或不是java? - How can I know if my sent email reach the receiver or not java? 为什么我不能在java中达到内部类的方法? - Why can't I reach methods of inner class in java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM