How do I populate a drop down with a list using thymeleaf and spring

前端 未结 5 1915
天涯浪人
天涯浪人 2020-11-29 06:26

I need to populate a drop down with all the values within a list of strings.

Controller Class

@RequestMapping(value = \"/generateIds\", method = Requ         


        
5条回答
  •  情话喂你
    2020-11-29 07:07

    I have implemented a similar where i need to populate the dropdown from the database. For that I retrieved the data from the controller as below

    @GetMapping("/addexpense")
    public String addExpense(Expense expense,Model model){
        model.addAttribute("categories",categoryRepo.findAll());
        return "addExpense";
    }
    

    Then in the thymeleaf I have used the below code.

提交回复
热议问题