0

From looking at the thymeleaf documentation, I've tried to access web context objects with thymeleaf in my Spring boot project in this manner:

<p th:text="${#request.getRequestURL()}">lol</p>

which results in the following exception:

org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: 
Attempted to call method getRequestURL() on null context object

From this error it seems that I might be missing a dependency? I've seen a similar question, where the solution was to add an extras thymeleaf package as a dependency.

However, it is stated in the thymeleaf documentation that these objects and variable maps are always available to be invoked so I guess that shouldn't be the case here.

I'm using the release 1.5.1 of spring-boot-starter-thymeleaf as well as a number of other spring-boot-starter packages like web and security.

Community
  • 1
  • 1
  • 1
    just tried and it is working fine by using `thymeleaf 3.0.2.RELEASE`, `thymeleaf-layout-dialect 2.1.1` and `spring boot 1.4.3.RELEASE`. No extra module needed. – Paizo Mar 16 '17 at 09:57
  • You're right. Found out that a minimum of `thymeleaf-spring4:3.0.0.RELEASE` and `thymeleaf-layout-dialect 2.0.0` are required to access web context objects. – Mikeyboy8230 Mar 16 '17 at 16:24

1 Answers1

0

I got it to work with thymeleaf-spring4:3.0.0.RELEASE and thymeleaf-layout-dialect 2.0.0, so seems like these are the minimum versions required.

The spring-boot-starter-thymeleaf:1.5.1.RELEASE only provides thymeleaf-spring4:2.1.5.RELEASE and thymeleaf-layout-dialect 1.4.0.