Spring-boot: Thymeleaf: "Template mode "TEXT" has not been configured

Created on 10 Apr 2017  ·  7Comments  ·  Source: spring-projects/spring-boot

spring-boot:1.5.2 w/ spring-boot-starter-thymeleaf

I need to write an @Controller that will deliver a .txt file to a third party commercial application. This seems harder than it should.

According to https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html under # THYMELEAF I require the following properties:

--spring.thymelead.content-type=text/plain
--spring.thymeleaf.mode=TEXT
--spring.thymeleaf.suffix=.txt

This does not result in the downloading of my src/main/resources/templates/updates.txt with run-time values applied but an error page telling me that "TEXT" has not been configured.

I was hoping given the available configuration properties and thymeleaf's claim that everything works "out of the box" this would be all that was required. It seems not :-(

stackoverflow

Most helpful comment

For anyone else hitting this problem it is because spring-boot:1.5 depends on thymeleaf 2.x which does not support more than XML and HTML.

All 7 comments

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

For anyone else hitting this problem it is because spring-boot:1.5 depends on thymeleaf 2.x which does not support more than XML and HTML.

@jmkgreen check the documentation: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-thymeleaf-3

@jmkgreen The “spring.thymelead.content-type=text/plain” should be written to “spring.thymeleaf.content-type=text/plain” ,right ?

@sincewhen yes. Not that I think it would have made much difference - perhaps a "Not supported" error message to at least end the speculation.

@jmkgreen check the documentation: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-thymeleaf-3

For Spring 1.5.x you need to use https://docs.spring.io/spring-boot/docs/1.5.10.RELEASE/reference/htmlsingle/ because the _current_ documentation now points to 2.0.0.RELEASE.

Was this page helpful?
0 / 5 - 0 ratings