0

The code works nice. But the exercise says to do it with "links" and so I would want a way to do it with a link and not with a submit button/form. Is there a way?

Index page:

<form action="/resultaat/groterdan" method="post">
    <label for="groterdan">Lijst met betalingen groter dan: </label><input type="text" 
                                                             name="groterdan" id="groterdan"><input
        type="submit" value="Parameter Verzenden">
</form>

Controller:

@RequestMapping("/resultaat/groterdan")
public String groterdan(Model model, HttpServletRequest request){
    Double referentie = Double.valueOf(request.getParameter("groterdan"));
    List<Betaling> betalingsLijst = betaalRepository.geefLijstBetalingGroterDan(referentie);
    model.addAttribute("betalingsLijst",betalingsLijst);
    return "resultaat";
}

Repository

@Query("SELECT b from Betaling b where b.bedrag > :referentie")
List<Betaling> geefLijstBetalingGroterDan(Double referentie);
rkosegi
  • 14,165
  • 5
  • 50
  • 83
Johan Belien
  • 59
  • 1
  • 8
  • Either style the button to look like a link -- something like this for example: https://stackoverflow.com/questions/1367409/how-to-make-button-look-like-a-link -- or use javascript. There is no standard HTML way to do this. – Metroids May 24 '21 at 15:39
  • @Metroids, that would do it when I was free to do it. But within the Java course I cannot do it like that. They ask to do it with a link. But thanks for the answer, it can help in the future when I am free of exercises :-).. – Johan Belien May 25 '21 at 16:08

0 Answers0