I am trying to call a method that returns a model and prints out a simple message to the console using Thymeleaf. However, I realize that whenever I setup the action to be called it does not work the way I want it to. The function does not get called. I have also tried to use th:action
instead but still get the same issue of it not getting the model and not doing the System.out.print("Works") line of code. I have been stuck so long on this issue and have read some documentation, but I can't seem to figure out a way to solve it.
Java:
@GetMapping("/createSelector")
@ResponseBody
public String getCreationSelector() {
selectorList.add(new Selector());
System.out.println("Test Works");
return "The size is: " + selectorList.size();
}
Thymeleaf:
<div class="row justify-content-md-center">
<a th:href="@{/createSelector}" id="selectorBtn"><button
class="btn btn-sm btn-block eNew">New Tier</button></a>
</div>