spring-mvc - SpringMVC+T​​hymeleaf ,错误信息是 : template might not exist or might not be accessible by any of the configured Template Resolvers

标签 spring-mvc thymeleaf

我已经阅读了其他答案,但没关系,谢谢

Spring :



<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
    <property name="templateResolver" ref="templateResolver" />
</bean>

<bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
    <property name="templateEngine" ref="templateEngine" />
    <property name="order" value="1" />
</bean>

pom.xml:
<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf</artifactId>
    <version>2.0.13</version>
</dependency>
<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf-spring3</artifactId>
    <version>2.0.13</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
    </exclusions>
    <scope>compile</scope>
</dependency>

org.thymeleaf.exceptions.TemplateInputException:解析模板“login.html”时出错,模板可能不存在或可能无法被任何配置的模板解析器访问

最佳答案

您需要模板解析器吗?

尝试这样的事情:

<bean id="templateResolver"
      class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
    <property name="prefix" value="/WEB-INF/" />
    <property name="templateMode" value="HTML5" />
 </bean>

确保/path/after/web-inf/login.html 由 Spring MVC Controller 返回。

关于spring-mvc - SpringMVC+T​​hymeleaf ,错误信息是 : template might not exist or might not be accessible by any of the configured Template Resolvers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15777425/

相关文章:

html - 图像不显示在使用 Spring Boot、 Flying Saucer 和 Thymeleaf 的 PDF 模板中

thymeleaf - Thymeleaf 中的标题和标题

spring-mvc - A/B,使用 Spring MVC 进行多变量测试

java - 如何在 Spring MVC 错误处理程序中打印堆栈跟踪

java - SpringBoot Controller 无法解析名称为 'home' 的 View

java - @Value 用于在 Spring 3 中初始化 java.util.Date

java - Spring Web Flow 空白绑定(bind)应该为 null,而不是空字符串

java - 重定向不适用于 Spring Boot 应用程序中的 Thymeleaf

java.sql.SQLIntegrityConstraintViolationException : Cannot add or update a child row: a foreign key constraint fails

spring-boot - 如何访问 Thymeleaf 中的 contextPath?