I am new to Thymeleaf. I am having an issue taking the place holder value from the user(frontend) and storing it into my Url. I am trying to take the id value from the user and using findById operation to search the database and render the information to the browser. But when I manually enter the id number in the url it finds the customer.
Controller
@GetMapping("/withdrawal")
public String withdrawal(Model model) {
CheckingAccount checkingAccount = new CheckingAccount();
model.addAttribute("checkingAccount", checkingAccount);
return "find_checking_account";
}
@GetMapping("/findcheckingaccount/{id}")
public String getAccount(@PathVariable("id") Integer checkingId, Model model) {
CheckingAccount checkingAccount = checkingService.getAccount(checkingId);
model.addAttribute("checkingAccount", checkingAccount);
return "Found_checking_account";
}
Html
<body>
<div class="container 2">
<h1>Find Checking Account</h1>
<hr>
<form action = "#" th:action="@{/findcheckingaccount/{Id}(Id=${checkingId})}" method="get">
<div>
<a th:if{checkingAccount}>
<input type="number" th:field="*{checkingAccount.checkingId}" placeholder="Enter Account Id" class="form-control mb-4 col-4">
<button type="submit" class="btn btn-info col-2"> Find </button>
</a>
</div>
</form>
</div>
</body>
Error message
Manually entering the id number it works !!
question from:
https://stackoverflow.com/questions/65840092/having-issues-passing-placeholder-value-in-thymeleaf-to-url 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…