Java 如何将多记录HTML表单数据绑定到AutoPopulationGlist

Java 如何将多记录HTML表单数据绑定到AutoPopulationGlist,java,spring,spring-mvc,freemarker,Java,Spring,Spring Mvc,Freemarker,我正在构建一个分页表单,它允许逐页遍历整个“Book”表,并允许一次提交更新整个记录页 屏幕将具有一个二维表单,具有文本框的行和列,如电子表格,其中每行对应页面中的一个图书对象,每列对应图书对象的字段 采取的步骤: 1.使用分页和排序存储库检索页面记录 2.将图书列表复制到由AutoPopulationGlist支持的FormBean中 我在屏幕上使用freemarker模板(因为SpringBoot文档建议在开发SpringBoot应用程序时避免使用JSP) 需要以下方面的帮助: Q1)如何将

我正在构建一个分页表单,它允许逐页遍历整个“Book”表,并允许一次提交更新整个记录页

屏幕将具有一个二维表单,具有文本框的行和列,如电子表格,其中每行对应页面中的一个图书对象,每列对应图书对象的字段

采取的步骤: 1.使用分页和排序存储库检索页面记录

2.将图书列表复制到由AutoPopulationGlist支持的FormBean中

我在屏幕上使用freemarker模板(因为SpringBoot文档建议在开发SpringBoot应用程序时避免使用JSP)

需要以下方面的帮助: Q1)如何将AutoPopulationGlist绑定到freemarker的@Spring.bind并呈现一行@Spring.formInput文本框(每个图书字段一个文本框)(目前我使用纯html和freemarker标记呈现)

Q2)如何将提交的表单值读入myFormBean.AutoPopulatingList

我的菜豆
//由AutoPopulatingList支持的表单Bean
//使用AutoPopulationGlist允许灵活的页面大小
公共类MyBookListFormBean{
私人自动出版英语图书目录;
//getter、setter、constructor
公共作废添加(图书列表){
booksList.addAll(books);//将分页数据复制到AutoPopulatingList中
}
}
控制器方法
//显示表单页方法。
//这允许在表格中导航
//并显示每页可提交到不同URL的数据的表单屏幕。
//单击表单下方的“第一个/上一个/下一个/最后一个”链接时,将运行此方法
@请求映射(value=“/books”)
公共字符串showPagedForm(模型、可分页页面、,
@ModelAttribute(“BookForm”)MyBookListFormBean(formBean){
Page allBooks=booksRepository.findAll(可分页);
model.addAttribute(“booksPage”,allBooks);
addToList(allBooks.getContent());//将当前页面数据添加到表单Bean
返回“/书籍/索引”;
}
//提交表格
@RequestMapping(value=“/books/updateAppageOfRecords”方法=RequestMethod.POST)
公共字符串UpdatePageOfRecords(模型、可分页页面、,
@ModelAttribute(“BookForm”)MyBookListFormBean formBean,
BindingResult(结果){
//试图打印提交的数据
//什么都没有被束缚!!!
}
//Form Bean backed by AutoPopulatingList
//Use AutoPopulatingList to allow flexible page sizes
public class MyBookListFormBean {

    private AutoPopulatingList<Book>  booksList;
    //getter, setter, constructor
    public void add(List<Book> books) {
        booksList.addAll(books); //copy paged data into AutoPopulatingList 
    }
}
  //show Form page method. 
  //This allows to navigate through the table 
  //and show a form screen per page of data which can be submitted to different URL. 
  //this method is run when "first/prev/next/last" links below the form are clicked
  @RequestMapping(value="/books")
  public String showPagedForm(Model model, Pageable page,
                @ModelAttribute("booksForm") MyBookListFormBean formBean ) {

    Page<Book> allBooks = booksRepository.findAll(pageable);
    model.addAttribute("booksPage",allBooks); 
    formBean.addToList(allBooks.getContent());  //add current page data to Form Bean
    return "/books/index";
  }


  //submit Form
  @RequestMapping(value="/books/updateAPageOfRecords" method=RequestMethod.POST)
  public String updateAPageOfRecords( Model model, Pageable page, 
         @ModelAttribute("booksForm") MyBookListFormBean formBean, 
         BindingResult result  )   {
    //tried to print the submitted data
    //NOTHING got bound !!!

  }