springboot+thymeleaf:解析模板失败

von4xj4u  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(230)

我想在html中显示一个请求的对象,我得到一个错误,我不知道是什么原因导致我的错误。谷歌帮不上忙,现在我试着问你。我不认为这个错误来自我的表,因为我把它注解掉了,错误仍然存在。错误也不是来自http://localhost:8081/simulation“因为我用有效值重新发送了一个有效的json。感谢您的帮助:)。
这是我的密码:
apicontroller.java:

package de.WI18C.Gruppe5.API.controller;
import de.WI18C.Gruppe5.API.model.Unternehmen;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@Controller
public class APIContoller {

@RequestMapping(value = "/unternehmen", method = RequestMethod.GET)
public String viewUnternehmen(Model model) {
    RestTemplate restTemplate = new RestTemplate();
    Unternehmen unternehmen = restTemplate.getForObject("http://localhost:8081/simulation", Unternehmen.class);
    model.addAttribute("unternehmen", unternehmen);

    return "unternehmen";
   }
}

unternehmen.html网址:

<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" lang="de">
<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>Unternehmen</title>
</head>
<body>

<div class="col-12 align-content-center">
    <div class="row">
        <div class="col-8 mx-auto">
            <table class="table">
                <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Attribut</th>
                    <th scope="col">Wert</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th scope="row">1</th>
                    <td>Name</td>
                    <td th:text="${unternehmen.getName()}"></td>
                </tr>
                <tr>
                    <th scope="row">2</th>
                    <td>Bestand</td>
                    <td th:text="${unternehmen.getBestand()}"></td>
                </tr>
                <tr>
                    <th scope="row">3</th>
                    <td>Bedarf</td>
                    <td th:text="${unternehmen.getBedarf()}"></td>
                </tr>
                <tr>
                    <th scope="row">4</th>
                    <td>Verkaufspreis</td>
                    <td th:text="${unternehmen.getVerkaufspreis()}"></td>
                </tr>
                <tr>
                    <th scope="row">5</th>
                    <td>Gewinn</td>
                    <td th:text="${unternehmen.getGewinn()}"></td>
                </tr>
                <tr>
                    <th scope="row">6</th>
                    <td>Bestand - Rad</td>
                    <td th:text="${unternehmen.getBestand_rad()}"></td>
                </tr>
                <tr>
                    <th scope="row">7</th>
                    <td>Bestand - Rahmen</td>
                    <td th:text="${unternehmen.getBestand_rahmen()}"></td>
                </tr>
                <tr>
                    <th scope="row">8</th>
                    <td>Bestand - Lenker</td>
                    <td th:text="${unternehmen.getBestand_lenker()}"></td>
                </tr>
                <tr>
                    <th scope="row">9</th>
                    <td>Bestand - Licht</td>
                    <td th:text="${unternehmen.getBestand_licht()}"></td>
                </tr>
                <tr>
                    <th scope="row">10</th>
                    <td>Bestand - Schaltung</td>
                    <td th:text="${unternehmen.getBestand_schaltung()}"></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<!-- 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>

“我打电话得到的错误”http://localhost:8080/unternehmen“(抱歉格式化不好):
2020-12-16 15:07:55.635错误3696---[nio-8080-exec-1]org.thymeleaf.templateengine:[thymeleaf][http-nio-8080-exec-1]异常处理模板“unternehmen”:模板解析过程中发生错误(模板:“class path resource[templates/unternehmen.html]”)
org.thymeleaf.exceptions.templateinputexception:在org.thymeleaf.templateparser.markup.abstractmarkuptemplateparser.parse(abstractmarkuptemplateparser)的模板解析(模板:“class path resource[templates/unternehmen.html]”)过程中发生错误。java:241)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.templateparser.markup.abstractmarkuptemplateparser.parsestandalone(abstractmarkuptemplateparser)。java:100)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.engine.templatemanager.parseandprocess(templatemanager。java:649)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.templateengine.process(templateengine。java:1098)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.templateengine.process(templateengine。java:1072)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.spring5.view.thymeleafview.renderfragment(thymeleafview。java:362) ~[thymeleaf-spring5-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.spring5.view.thymeleafview.render(thymeleafview。java:189)~[thymeleaf-spring5-3.0.11.发布。jar:3.0.11.release]位于org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet。java:1394)~[spring-webmvc-5.3.1。jar:5.3.1]在org.springframework.web.servlet.dispatcherservlet.processDispatcherResult(dispatcherservlet。java:1139)~[spring-webmvc-5.3.1。jar:5.3.1]在org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet。java:1078)~[spring-webmvc-5.3.1。jar:5.3.1]在org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet。java:961)~[spring-webmvc-5.3.1。jar:5.3.1]位于org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet。java:1006)~[spring-webmvc-5.3.1。jar:5.3.1]位于org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet。java:898) ~[spring-webmvc-5.3.1。jar:5.3.1]在javax.servlet.http.httpservlet.service(httpservlet。java:626)~[tomcat-embed-core-9.0.39。jar:4.0.fr]位于org.springframework.web.servlet.frameworkservlet.service(frameworkservlet。java:883)~[spring-webmvc-5.3.1。jar:5.3.1]在javax.servlet.http.httpservlet.service(httpservlet。java:733) ~[tomcat-embed-core-9.0.39。jar:4.0.fr]位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:231)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter。java:53)~[tomcat-embed-websocket-9.0.39。jar:9.0.39]位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166) ~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.springframework.web.filter.requestcontextfilter.dofilterinternal(requestcontextfilter。java:100)~[spring-web-5.3.1。jar:5.3.1]在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:119)~[spring-web-5.3.1。jar:5.3.1]在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.springframework.web.filter.formcontentfilter.dofilterinternal(formcontentfilter。java:93)~[spring-web-5.3.1。jar:5.3.1]在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:119)~[spring-web-5.3.1。jar:5.3.1]位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193) ~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.springframework.web.filter.characterencodingfilter.dofilterinternal(characterencodingfilter。java:201)~[spring-web-5.3.1。jar:5.3.1]在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:119)~[spring-web-5.3.1。jar:5.3.1]位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve。java:202)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve。java:97) ~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase。java:542)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve。java:143)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve。java:92)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve。java:78)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.catalina.connector.coyoteadapter.service(coyoteadapter。java:343) ~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.coyote.http11.http11processor.service(http11processor。java:374)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.coyote.abstractprocessorlight.process(abstractprocessorlight。java:65)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.coyote.abstractprotocol$connectionhandler.process(抽象协议。java:868)~[tomcat-embed-core-9.0.39。jar:9.0.39]位于org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint)。java:1590)~[tomcat-embed-core-9.0.39。jar:9.0.39]在org.apache.tomcat.util.net.socketprocessorbase.run(socketprocessorbase。java:49) ~[tomcat-embed-core-9.0.39。jar:9.0.39]位于java.base/java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor。java:1130)~[na:na]位于java.base/java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor。java:630)~[na:na]位于org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread。java:61) ~[tomcat-embed-core-9.0.39。jar:9.0.39]在java.base/java.lang.thread.run(thread。java:832)~[na:na]原因:org.attoparser.parseexception:org.attoparser.markupparser.parsedocument(markupparser)的名称不能为null或空。java:393)~[attoparser-2.0.5.发布。jar:2.0.5.release]在org.attoparser.markupparser.parse(markupparser。java:257) ~[attoparser-2.0.5.发布。jar:2.0.5.release]位于org.thymeleaf.templateparser.markup.abstractmarkuptemplateparser.parse(abstractmarkuptemplateparser)。java:230)~[thymeleaf-3.0.11.发布。jar:3.0.11.release] ... 48省略公共帧的原因:java.lang.illegalargumentexception:name在org.thymeleaf.engine.attributenames.forhtmlname(attributenames)处不能为null或空。java:478)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]位于org.thymeleaf.engine.attributedefinitions$attributedefinitionrepository.storeattribute(attributedefinitions。java:788) ~[thymeleaf-3.0.11.发布。jar:3.0.11.release]位于org.thymeleaf.engine.attributedefinitions$attributedefinitionrepository.getattribute(attributedefinitions。java:677)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]位于org.thymeleaf.engine.attributedefinitions.forhtmlname(attributedefinitions)。java:405)~[thymeleaf-3.0.11.发布。jar:3.0.11.release] 在org.thymeleaf.engine.attributedefinitions.forname(attributedefinitions。java:336)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]位于org.thymeleaf.engine.templatehandleradaptermarkuphandler.handleattribute(templatehandleradaptermarkuphandler)。java:492)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.templateparser.markup.inlinedoutputexpressionmarkuphandler$inlineMarkupAdapterProcessorHandler.handleattribute(inlinedoutputexpressionmarkuphandler)。java:360)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.thymeleaf.standard.inline.outputExpressionInlinePreprocessHandler.handleattribute(outputExpressionInlinePreprocessHandler)。java:260)~[thymeleaf-3.0.11.发布。jar:3.0.11.release]位于org.thymeleaf.templateparser.markup.inlinedoutputexpressionmarkuphandler.handleattribute(inlinedoutputexpressionmarkuphandler)。java:205) ~[thymeleaf-3.0.11.发布。jar:3.0.11.release]在org.attoparser.htmlelement.handleattribute(htmlelement。java:250)~[attoparser-2.0.5.发布。jar:2.0.5.release]位于org.attoparser.htmlmarkuphandler.handleattribute(htmlmarkuphandler)。java:529)~[attoparser-2.0.5.发布。jar:2.0.5.release]在org.attoparser.markupeventprocessorhandler.handleattribute(markupeventprocessorhandler。java:593)~[attoparser-2.0.5.发布。jar:2.0.5.release]在org.attoparser.parsingattributesequenceutil.parseattributesequence(parsingattributesequenceutil。java:220)~[attoparser-2.0.5.发布。jar:2.0.5.release]在parseopenelement(parsingelementmarkuputil。java:153)~[attoparser-2.0.5.发布。jar:2.0.5.release]在org.attoparser.markupparser.parsebuffer(markupparser。java:710)~[attoparser-2.0.5.发布。jar:2.0.5.release]在org.attoparser.markupparser.parsedocument(markupparser。java:301) ~[attoparser-2.0.5.发布。jar:2.0.5.release] ... 省略50个公共框架
2020-12-16 15:07:55.638错误3696---[n]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题