attribute not being set.

when opening the page I get: ID: ${id} Insetad of ID: 6be5ede5-2393-40a0-9cab-48364af0d541
// Serve the verification page with CAPTCHA, video, and optional username
@GetMapping("/verify/{id}")
public String serveVerificationPage(@PathVariable String id, Model model) {
if (verificationService.isIdValid(id)) {
model.addAttribute("id", id); // Pass the ID to the HTML template
return "captcha-page"; // Serve the CAPTCHA and video HTML page
}
else {
return "error"; // Return an error page if the ID is invalid or already verified
}
}
// Serve the verification page with CAPTCHA, video, and optional username
@GetMapping("/verify/{id}")
public String serveVerificationPage(@PathVariable String id, Model model) {
if (verificationService.isIdValid(id)) {
model.addAttribute("id", id); // Pass the ID to the HTML template
return "captcha-page"; // Serve the CAPTCHA and video HTML page
}
else {
return "error"; // Return an error page if the ID is invalid or already verified
}
}
html: <h1>ID: ${id}</h1>
6 Replies
JavaBot
JavaBot5mo ago
This post has been reserved for your question.
Hey @Hype_the_Time! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
lisan
lisan5mo ago
show whole html
lisan
lisan5mo ago
you have to use thymeleaf and do something like this:
<td th:text="${student.id}"></td>
<td th:text="${student.id}"></td>
Hype_the_Time
Hype_the_TimeOP5mo ago
how would i do it in the submit button? i also get ${id} there as id in spring
@PostMapping("/verify/{id}")
public String verifyCaptchaAndSubmit(@RequestParam("cf-turnstile-response") String captchaResponse,
@RequestParam(value = "username", required = false) String username,
@PathVariable String id, Model model) {
//id is the "${id}"
}
@PostMapping("/verify/{id}")
public String verifyCaptchaAndSubmit(@RequestParam("cf-turnstile-response") String captchaResponse,
@RequestParam(value = "username", required = false) String username,
@PathVariable String id, Model model) {
//id is the "${id}"
}
JavaBot
JavaBot5mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?