Как после обновление страницы обновлять значение рандома в коде?
public class Captcha {
private final List<String> list = new ArrayList<>(Arrays.asList("qwert1","ahb28fsa","p3fe@","p09kfQ"));
public String getList() {
int a = (int) (Math.random() * 3);
return list.get(a);
}
}
Контролер
@GetMapping("/buy")
public String buyPage(Model model) {
model.addAttribute("cap", neBot);
return "buy-page";
}
@PostMapping("/buy")
public String emailInfo(@RequestParam String mail, @RequestParam String name, @RequestParam String phone, @RequestParam String text,@RequestParam String captcha,Model model){
if (captcha.equals(neBot)){
Email email = new Email(mail, name, phone, text);
emailRepository.save(email);
}
return "redirect:/";
}
форма html
<form action="/buy" method="post">
<img class="mb-4" src="https://static.vecteezy.com/ti/vecteur-libre/p1/2775409-pharmacie-pharmacie-vector-logo-vectoriel.jpg" alt="" width="150" height="140">
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
<div class="form-floating m-auto">
<input type="email" class="form-control" id="floatingInput" placeholder="[email protected]" name="mail">
<label for="floatingInput">Email address</label>
</div>
<br>
<div class="form-floating">
<input class="form-control" id="floatingPhone" placeholder="phone" type="text" name="phone">
<label for="floatingPhone">Phone</label>
</div>
<br>
<div class="form-floating">
<input class="form-control" id="floatingName" placeholder="your name" type="text" name="name">
<label for="floatingName">name</label>
</div>
<br>
<div class="form-floating">
<textarea class="form-control" id="ms" placeholder="Your order" type="text" name="text"></textarea>
<label for="ms">Your order</label>
</div>
<br>
<div class="form-floating">
<div>
<p th:text="'Каптча ' + ${cap}"></p>
</div>
</div>
<br>
<div class="form-floating">
<input class="form-control" id="floatingCaptcha" placeholder="phone" type="text" name="captcha">
<label for="floatingCaptcha">Captcha</label>
</div>
<br>
<button class="w-100 btn btn-lg btn-primary" type="submit">Send</button>
Есть такой код самодельной капчи как сделать что бы обновлялась значение капчи после обновление стр если такое можно сделать?