title: Conditional attribute using thymeleaf
body: <p>I know how to make a conditional attribute inside a tag on jstl:</p>
  
  <pre><code>&lt;body &lt;c:if test="${userCreated}"&gt; onload="somejavascriptfunction()"&lt;/c:if&gt; &gt;
  </code></pre>
  
  <p>But how do I do it using thymeleaf?</p>
  
  <p>IndexController</p>
  
  <pre><code>@RequestMapping("/register")
  public String register(UserEntity user, @RequestParam String repeatedPassword, RedirectAttributes redirectAttributes) {
      user.setAdmin(false);
      userFacade.create(user);
      redirectAttributes.addFlashAttribute(Constants.USER_CREATED, true);
      logger.info("Usuario criado");
      return "redirect:/login";
  }
  </code></pre>
  
  <p>So far the only solution I found was to do it like this</p>
  
  <pre><code>&lt;script type="text/javascript" th:if="${userCreated}"&gt;
    $(document).ready(function() {
       somejavascriptfunction()
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>But that doesn't seem to be the best way to do it. So how do I make an if statement for an attribute on thymeleaf?</p>