title: How to call object's method from Thymeleaf?
body: <p>My template do not see objects, passed from Spring.</p>
  
  <p>My code:</p>
  
  <pre><code>public class PublicModelAndView extends ModelAndView {
  
      @Autowired
      TemplateModulesHandler templateModulesHandler;
  
      public void init() {
  
          setViewName("index");
          CSSProcessor cSSProcessor = new CSSProcessor();
          cSSProcessor.setSiteRegion("public");
          super.addObject("CSSProcessor", cSSProcessor);
  
          JSProcessor jSProcessor = new JSProcessor();
          super.addObject("JSProcessor", jSProcessor);
  
          templateModulesHandler.setPublicModelAndView(this);
  
      }
  
  }
  </code></pre>
  
  <p>Contoller's code:</p>
  
  <pre><code>@SpringBootApplication
  @Controller
  public class IndexPage {
  
      @Autowired
      PublicModelAndView publicModelAndView;
      @Autowired
      OurServicesBean ourServicesBean;
      @Autowired
      PortfolioBean portfolioBean;
  
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public ModelAndView indexPage() {
  
          publicModelAndView.setTemplate("publicSiteIndexPage");
          publicModelAndView.addObject("ourServices", ourServicesBean.getMenu());
          publicModelAndView.addObject("portfolioWorkTypes", portfolioBean.getWorkTypes());
          publicModelAndView.addObject("portfolioWorks", portfolioBean.getWorks());
  
          return publicModelAndView;
  
      }
  
  }
  </code></pre>
  
  <p>Main template's code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:th="http://www.thymeleaf.org"
        &gt;
      &lt;head th:include="headerAndFooter/fragments/header :: publicSiteHeader"&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          hello!
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Fragment's code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:th="http://www.thymeleaf.org"&gt;
  
      &lt;head th:fragment="publicSiteHeader"&gt;
  
          &lt;title&gt;SOME TITLE&lt;/title&gt;
  
           ${CSSProcessor.setDebugCaller("Public")}
           ${CSSProcessor.setSiteRegion("public")}
           ${CSSProcessor.addCSS("/css/main.css")}
      &lt;/head&gt;
      &lt;body&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As result I see code of the method calling, like</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
  
          &lt;title&gt;SOME TITLE&lt;/title&gt;
  
           ${CSSProcessor.setDebugCaller("Public")}
           ${CSSProcessor.setSiteRegion("public")}
           ${CSSProcessor.addCSS("/css/main.css")}
  </code></pre>
  
  <p>Why thymeleaf didn't call methods, but print this text at the output page? In example from <a href="http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html" rel="noreferrer">http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html</a> method calling has same syntax, like  </p>
  
  <pre><code>${person.createCompleteName()}
  </code></pre>
  
  <p>The same code works good with JSP, but do not work with thymeleaf.</p>