How to pass data from <form:select> Spring MVC

前端 未结 1 1939
说谎
说谎 2020-12-10 14:17

I would like to share my problem with you.

I built on jsp page and use on my page some of it use to

1条回答
  •  盖世英雄少女心
    2020-12-10 15:07

    I believe you should use inside the .

    It should look like this:

    search.jsp:

    
      
         --SELECT--
        
      
      ...
    
    

    HomeController.java:

    @RequestMapping(value = "/search", method = RequestMethod.GET)
    public String search(Model model) {
      ...
      model.addAttribute("myform", new MyForm());
      return "search";
    }
    
    @RequestMapping(value = "/result", method = RequestMethod.GET)
    public String SecondActionPage(@RequestParam String nameOfInstitution,
        Model model,
        @ModelAttribute("myform") MyForm myform)
        throws Exception {
      ...
    }
    

    MyForm.java:

    public class MyForm {
      private String nameOfInstitution;
    
      public String getNameOfInstitution() {
        return nameOfInstitution;
      }
    
      public void setNameOfInstitution(String nameOfInstitution) {
        this.nameOfInstitution = nameOfInstitution;
      }
    }
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题