thymeleaf-spring icon indicating copy to clipboard operation
thymeleaf-spring copied to clipboard

Fragment is not proberly rendered if fragment name contains "."

Open sascha08-15 opened this issue 1 year ago • 0 comments

For BUGS:

Expected behavior (option 1): Fragments of arbitrary names (including a ".") are rendered correctly. One gets the body rendered and a 200 OK.

Expected behavior (option 2): Fragment names including a "." are not supported. I'd expect an error message then and not a 200 OK.

Actual behaviour: I get a 200 OK response if the fragment is stored correctly and it is also found; however, it is never really returned, instead I get an empty reponse body.

I managed to trace the issue to the occurance of a "." in the fragment name.

Please provide the maximum detail possible. We will specifically need:

  • Version of Thymeleaf (and any involved extensions) you are using. 3.1.2
  • Environment: versions of Spring, Spring Boot, or any other relevant libraries. Spring Boot 3.3.5
  • Detailed steps to reproduce your issue.
  1. Create a controller
   @GetMapping("/test")
   public String test(final Model model)  {
      return "TestEntity-two :: testEntity.oneTwo";
   }
  1. In your template TestEntity-two.html, put a fragement:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org" >
<head>
    <title>TestEntity</title>
</head>
<body>
    <div th:fragment="testEntity.oneTwo" id="testEntity">
        Renders OK
    </div>
</body>
</html>
  • Any possible workarounds you may have found.

Omitting the "." in the fragment name works

sascha08-15 avatar Nov 01 '24 11:11 sascha08-15