0
votes

I am getting parsing error when I try to load localhost:8080/.

I can't find any errors in my template, so why have I this mistake?

The file static has folder css and picture with jQuery, js and bootstrap

Error : This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed May 22 13:02:18 CEST 2019
There was an unexpected error (type=Internal Server Error, status=500).
An error happened during template parsing (template: "class path resource [templates/RHAjouterDeve.html]")

Code layout index.html:

<!DOCTYPE html>
<html lang="fr" xmlns:th="http://www.thymeleaf.org" 
                xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> 
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial- scale=1">
        <link th:href="/webjars/bootstrap/4.3.1/css/bootstrap.css" rel="stylesheet" /> 
        <link rel="icon" th:href="(images/favicon.ico)" type="image/ico" />
        <title>Projet Pfa Spring BOOT </title>
        <link rel="stylesheet" th:href="{build/css/bootstrap.min.css}" />
    </head>
    <body class="nav-md">
        <div class="container body">
            <div class="main_container">
                <div class="col-md-3 left_col">
                    <div class="left_col scroll-view">
                       <div class="navbar nav_title" style="border: 0;">

                       </div>
                       <div class="clearfix"></div>

                       <div class="profile clearfix">
                          <div class="profile_pic">
                          </div>
                       </div>

            <br />


            <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
              <div class="menu_section">
              <br/>
               <br/>
                <br/>
                <br/>
                <br/>
                <h3>Menu</h3>
                <!-- <ul class="nav side-menu"> -->
                  <!-- <li><a><i class="fa fa-home"></i> Formation <span class="fa fa-chevron-down"></span></a> -->
                    <!-- <ul class="nav child_menu"> -->
                      <!-- <li><a href="Demande_Formation.html">Demande Formation</a></li> -->
                       <!-- <li><a href="Demande_Formation.html">Formation Traité</a></li> -->
                      <!-- <li><a href="Formation_Accepter.html">Formation Accepter</a></li> -->
                      <!-- <li><a href="Formation_En_Cours.html">Formation En Cours</a></li> -->
                      <!-- <li><a href="Formation_Finis.html">Formation Finis</a></li> -->
                    <!-- </ul> -->
                  <!-- </li> -->

                  <!-- <ul class="nav side-menu"> -->
                  <!-- <li><a><i class="fa fa-home"></i> Devellopeur <span class="fa fa-chevron-down"></span></a> -->
                    <!-- <ul class="nav child_menu"> -->

                       <!-- <li><a href="Devellopeur.html">La Liste Devellopeur</a></li> -->

                    <!-- </ul> -->
                  <!-- </li> -->

             <!--     </ul>-->
              </div>
              </div>


          </div>
        </div>

        <!-- top navigation -->
        <div class="top_nav">
          <div class="nav_menu">
            <nav>
              <div class="nav toggle">
                <a id="menu_toggle"><i class="fa fa-bars"></i></a>
              </div>

              <ul class="nav navbar-nav navbar-right">
                <li class="">
                  <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <img th:src="(images/img.jpg)" alt="">



                    <span class=" fa fa-angle-down"></span>
                  </a>
                  <ul class="dropdown-menu dropdown-usermenu pull-right">

                    <li>

                    </li>

                    <li><a href="login.html"><i class="fa fa-sign-out pull-right"></i> Log Out</a></li>
                  </ul>
                </li>

                <li role="presentation" class="dropdown">

                  <ul id="menu1" class="dropdown-menu list-unstyled msg_list" role="menu">
                    <li>
                      <a>
                        <span class="image"><img th:src="(images/img.jpg)" alt="Profile Image" /></span>


                      </a>
                    </li>
                    <li>
                      <a>
                        <span class="image"><img src="images/img.jpg" alt="Profile Image" /></span>


                      </a>
                    </li>
                    <li>
                      <a>



                      </a>
                    </li>
                    <li>
                      <a>



                      </a>
                    </li>
                    <li>
                      <div class="text-center">

                      </div>
                    </li>
                  </ul>
                </li>
              </ul>
            </nav>
          </div>
        </div>
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col" role="main">

          <!-- <div class="row tile_count"> -->
            <!-- <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count"> -->
              <!-- <span class="count_top"><i class="fa fa-user"></i> Formation en cours</span> -->
              <!-- <div class="count">2500</div> -->

            <!-- </div> -->
            <!-- <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count"> -->
              <!-- <span class="count_top"><i class="fa fa-user"></i> Formation Traité </span> -->
              <!-- <div class="count">123.50</div> -->
              <!-- <span class="count_bottom"><i class="green"> </i></span> -->
            <!-- </div> -->
            <!-- <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count"> -->
              <!-- <span class="count_top"><i class="fa fa-user"></i> Total Finis</span> -->
              <!-- <div class="count green">2,500</div> -->
              <!-- <span class="count_bottom"><i class="green"></i> </i></span> -->
            <!-- </div> -->
            <!-- <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count"> -->
              <!-- <span class="count_top"><i class="fa fa-user"></i> Total Formateur</span> -->
              <!-- <div class="count">4,567</div> -->
              <!-- <span class="count_bottom"><i class="red"></i> </i> </span> -->
            <!-- </div> -->
            <!-- <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count"> -->
              <!-- <span class="count_top"><i class="fa fa-user"></i> Total Employé</span> -->
              <!-- <div class="count">2,315</div> -->
              <!-- <span class="count_bottom"><i class="green"> </span> -->
            <!-- </div> -->
            <!-- <div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count"> -->
              <!-- <span class="count_top"><i class="fa fa-user"></i> Total Chef Projet</span> -->
              <!-- <div class="count">7,325</div> -->
              <!-- <span class="count_bottom"><i class="green"> </span> -->
            <!-- </div> -->
          <!-- </div> -->
                <section layout:fragment="content" class="container"> 

  </section>         






                <!-- start of weather widget -->

                <!-- end of weather widget -->
              </div>
            </div>
          </div>

        <!-- /page content -->

        <!-- footer content -->

        <!-- /footer content -->




    <!-- Custom Theme Scripts -->
    <script src="build/js/custom.min.js"></script>
    <script src="/webjars/jquery/3.4.1/jquery.js"></script> <script  src="/webjars/bootstrap/4.3.1/js/bootstrap.js"> 

</script> 

  </body>
</html>
</strike>


 Fichier rhajouterdeve.html
<strike><!DOCTYPE html>
<html xmlns:th="http://thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="layout/default">

<body>
 <section layout:fragment="content"> 

hello 
  </section>

 </body>
 </html>
</strike>

le code du controller :
package com.projetpfa.gestionrh.gestionrh.controllers;



import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;



@Controller
@RequestMapping("/Devellopeur")
public class DeveControllers {
    //@Autowired
    //DeveService dvserv;

    @GetMapping("/")
    public String AllDeve( )
    {

        return"RHAjouterDeve";
    }

}

mon fichier pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.projet.pfa</groupId>
    <artifactId>projetpfa</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>projetpfa</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
        <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.1-api</artifactId>
    <version>1.0.0.Final</version>
</dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

<dependency>
    <groupId>nz.net.ultraq.thymeleaf</groupId>
    <artifactId>thymeleaf-layout-dialect</artifactId>
    </dependency>
    <dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.4.1</version>
</dependency>


<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>bootstrap</artifactId>
    <version>4.3.1</version>
</dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Error in logs:

____org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/RHAjouterDeve.html]")
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362) [thymeleaf-spring5-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189) [thymeleaf-spring5-3.0.11.RELEASE.jar:3.0.11.RELEASE] at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1370) [spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1116) [spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055) [spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) [spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) [spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) [spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) [tomcat-embed-core-9.0.17.jar:9.0.17] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) [spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [tomcat-embed-core-9.0.17.jar:9.0.17] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-9.0.17.jar:9.0.17] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.17.jar:9.0.17] _ __ _ _ have a Spring Boot for serving images. My Model is included in my ImageController.java. ImageService contains findPage method.

When running my Spring Boot Application I am getting an error. I want to see me template DASHBOARD to begin my project How can localhost:8585/Devellopeur find template with static file and layout view with no error,

1
which page do you want to get displayed?Abhijeet

1 Answers

0
votes

First of all, you can not access localhost:8080/ because you do not have the right controller. You can access http://localhost:8090/Devellopeur/

package com.projetpfa.gestionrh.gestionrh.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/Devellopeur")
public class DeveControllers {
//@Autowired
//DeveService dvserv;

@GetMapping("/")
public String AllDeve( )
{
    return"RHAjouterDeve";
}
}

In order to access http://localhost:8090/Devellopeur/ without no thymeleaf parsing errors, you have to create the web page default declared in your rhajouterdeve.html. In general, this file (default.html) is used to to reuse header and footer on all Thymeleaf templates.

<html xmlns:th="http://thymeleaf.org"
 xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
 layout:decorator="layout/default">

Create it in templates package and declare it as follow:

<html xmlns:th="http://thymeleaf.org"
 xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
 layout:decorator="default">

At last, you should delete the <strike> in your rhajouterdeve.html

Here an example of default page that you can use.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>

    <meta charset="UTF-8">
    <title>Title</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>
<header>
    <div class="container">
        <nav class="navbar navbar-default" role="navigation">

            <div class="navbar-header">
                <a class="navbar-brand" href="#">Jeutroll</a>
            </div>

            <div>
                <ul class="nav navbar-nav">
                    <li class="active"><a th:href="@{/index}">Home</a></li>
                </ul>
            </div>

        </nav>
    </div>
</header>
<section layout:fragment="content"></section>
<footer>
    <div class="navabar-fixed-bottom">
        <small>adress</small>
    </div>
</footer>
</body>
</html>