Can a Thymeleaf fragment call a controller?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Can a Thymeleaf fragment call a controller?

newbo
Hey everyone,

I'm stuck with thymeleaf fragments.

I have a full page that I can get to through its controller, do its database calls and so on.  I have it in a Controller and page to get to the Autowired DAOs.  When I go to the page through the browser, it's fine.

When I try to put it in a fragment, I fail utterly.

<div id="divID" th:insert="~{/help/mypage}" class="row">
</div>

My Controller is:

@RequestMapping("/help/mypage")
public String getHelp(Model model) {
....stuff....
}

The /help/mypage fails gracefully and renders, but it doesn't go through the controller--it just goes to the page.  Is going through the controller even possible or does it just go through the template path?

I was interested in a fragment because I could reload the fragment (it's loaded down with custom controls).  Is there another option if I cannot get through the controller?

Thank you!