Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 属性名称不能为null或为空。MELEAF与Spring一起使用_Html_Spring_Spring Boot_Web_Themes - Fatal编程技术网

Html 属性名称不能为null或为空。MELEAF与Spring一起使用

Html 属性名称不能为null或为空。MELEAF与Spring一起使用,html,spring,spring-boot,web,themes,Html,Spring,Spring Boot,Web,Themes,我试图使用MELEAF将spring项目与管理仪表板模板集成。但是,当我试图运行该项目时,出现了以下问题: An error happened during template parsing (template: "class path resource [templates/index.html]") Caused by: java.lang.IllegalArgumentException: Attribute name cannot be null or empty 我在html中使用了

我试图使用MELEAF将spring项目与管理仪表板模板集成。但是,当我试图运行该项目时,出现了以下问题:

An error happened during template parsing (template: "class path resource [templates/index.html]")
Caused by: java.lang.IllegalArgumentException: Attribute name cannot be null or empty
我在html中使用了MELEAF链接,并编写了控制器以正确运行应用程序。然而,尽管我做了更改,但没有结果

DashBoardController.java

package io.javabrains.Dashboard;

import java.util.Date;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;



public class DashboardController {

     private static final String appName = "ThymeleafTour";

        @GetMapping("/")
        public String home(Model model,
                           @RequestParam(value = "name", required = false,
                                   defaultValue = "Guest") String name) {

            model.addAttribute("name", name);
            model.addAttribute("title", appName);
            return "home";

        }

}




build.gradle


plugins {
    id 'org.springframework.boot' version '1.5.8.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

group = 'io.javabrains.com'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-web-services'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    runtimeOnly 'mysql:mysql-connector-java'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
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, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <title th:text:="${title}">

  <!-- Custom fonts for this template-->
  <link href= "#" th:href="@{/vendor/fontawesome-free/css/all.min.css}" rel="stylesheet" type="text/css"/>
  <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet"/>

  <!-- Custom styles for this template-->
  <link href="#" th:href="@{//css/sb-admin-2.min.css}" rel="stylesheet"/>

</head>

<body id="page-top">

  <!-- Page Wrapper -->
  <div id="wrapper">

    <!-- Sidebar -->
    <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

      <!-- Sidebar - Brand -->
      <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
        <div class="sidebar-brand-icon rotate-n-15">
          <i class="fas fa-laugh-wink"></i>
        </div>
<h1 th:text="|Hello ${name}!|"></h1>
      </a>

      <!-- Divider -->
      <hr class="sidebar-divider my-0">

      <!-- Nav Item - Dashboard -->
      <li class="nav-item active">
        <a class="nav-link" href="index.html">
          <i class="fas fa-fw fa-tachometer-alt"></i>
          <span>Dashboard</span></a>
      </li>

      <!-- Divider -->
      <hr class="sidebar-divider">

      <!-- Heading -->
      <div class="sidebar-heading">
        Interface
      </div>

      <!-- Nav Item - Pages Collapse Menu -->
      <li class="nav-item">
        <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
          <i class="fas fa-fw fa-cog"></i>
          <span>Components</span>
        </a>
        <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
          <div class="bg-white py-2 collapse-inner rounded">
            <h6 class="collapse-header">Custom Components:</h6>
            <a class="collapse-item" href="buttons.html">Buttons</a>
            <a class="collapse-item" href="cards.html">Cards</a>
          </div>
        </div>
      </li>



  • 接口
  • 自定义组件:
有了这些代码,我认为project必须能够正常工作,不会出现错误。然而,console中仍会显示相同的错误