Thymeleaf +引导+ AngularJS指令解析错误 [英] Thymeleaf + Boot + AngularJS directives parser error

查看:2872
本文介绍了Thymeleaf +引导+ AngularJS指令解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是轻松的一年,但我无法找到任何解决办法吧。

this should be an easy one but I can't find any solution for it.

我使用Spring 1.0.2启动与Thymeleaf码头上支持我的AngularJS应用。但是解析器抛出使用属性的指令时异常。

I'm using Spring Boot 1.0.2 with Thymeleaf on Jetty to support my AngularJS application. But parser throws an exception when attribute directives are used.

的pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.nekohtml</groupId>
        <artifactId>nekohtml</artifactId>
        <version>1.9.20</version>
    </dependency>

Thymeleaf配置

Thymeleaf config

@Configuration
public class ThymeleafConfig {

@Bean
public ServletContextTemplateResolver templateResolver() {
    ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
    resolver.setPrefix("/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode("LEGACYHTML5");
    resolver.setCacheable(false);
    return resolver;
}

@Bean
public ResourceBundleMessageSource messageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename("messages");
    messageSource.setDefaultEncoding("UTF-8");

    return messageSource;
}
}

Thymeleaf是工作确定,但它与属性的指令像这样引导UI例如一个问题:

Thymeleaf is working ok but it has a problem with attribute directives like this Bootstrap UI example:

<div class="btn-group" dropdown is-open="true">
            <button type="button" class="btn btn-primary dropdown-toggle">Button dropdown <span       class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
            </ul>
        </div>

我收到此错误

org.xml.sax.SAXParseException: Attribute name "dropdown" associated with an element type "div" must be followed by the ' = ' character.

我在哪里可以调整Thymeleaf接受这些样的属性?

Where can I tweak Thymeleaf to accept those kind of attributes?

---编辑---

我添加nekoHTML解析器LEGACYHTML5,但仍然没有结果。

I've added nekoHTML parser for LEGACYHTML5 but still no result.

推荐答案

更改

@Bean
public ServletContextTemplateResolver templateResolver() { ... }

@Bean
public ServletContextTemplateResolver defaultTemplateResolver() { ... }

(注意默认设置)。

(notice default).

在你的情况,弹簧(引导)不使用配置Thymeleaf这样你得到有关分析非标准特性(因为默认解析器是XHTML)这个奇怪的错误。

In your case, spring (boot) is not using your configuration for Thymeleaf thus you're getting this "strange" error about parsing non-standard attribute (since default parser is XHTML).

这篇关于Thymeleaf +引导+ AngularJS指令解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆