title: Thymeleaf, fragments and default parameters
body: <p>I have created fragments.html file. It contains the following fragment:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;div th:fragment="my_fragment(content)"&gt;
      &lt;p th:text="${content}"&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I put the above fragment into my view file:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div th:replace="fragments :: my_fragment('test')"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Now, I want to pass two parameters to my_fragment, but I must ensure backward compatibility.</p>
  
  <p>I tried to solve the problem as follows:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div th:fragment="my_fragment(content, defaultParameter='default value')"&gt;
      &lt;p th:text="${content}"&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Unfortunelly, the above solution generated error:</p>
  
  <blockquote>
    <p>org.springframework.web.util.NestedServletException: Request
    processing failed; nested exception is
    org.thymeleaf.exceptions.TemplateProcessingException: Cannot resolve
    fragment. Signature "my_fragment (content,defaultParameter='default value')"
    declares 2 parameters, but fragment selection specifies 1 parameters.
    Fragment selection does not correctly match.</p>
  </blockquote>
  
  <p>Any idea?</p>