简体   繁体   English

Spring Boot和Thymeleaf-为后续通话保存搜索表的最佳方法

[英]Spring Boot & Thymeleaf - Best Way to Save a Search Form for subsequent calls

I am working on a Spring Boot app that implements a search form page so that the user is able to narrow search results, this works with Pageable and QueryDSL to fullfill all the needs, and I am temporaryly saving the search form on a bean to pass it to Spring Data and return the search results. 我正在开发一个实现搜索表单页面的Spring Boot应用程序,以便用户能够缩小搜索结果,它可以与Pageable和QueryDSL配合使用以满足所有需求,并且我暂时将搜索表单保存在bean上以通过将其发送到Spring Data并返回搜索结果。

The thing is, the results page implements links for the other pages of the search query like this 事实是,结果页面实现了搜索查询其他页面的链接,如下所示

First Page | 第一页 1 | 1 | 2 | 2 | 3 | 3 | 4 | 4 | 5 | 5 | …10 | …10 | Next 下一个

This links are like this: "/contract/nextPage?page=1&size=20” 该链接是这样的:“ / contract / nextPage?page = 1&size = 20”

But when the user, for example clicks on any of this links, obviously, I do not have anymore the "search parameters" that where on the first request to the controller. 但是,例如,当用户单击任何一个链接时,很明显,我再也没有在第一次向控制器发出请求时所处的“搜索参数”。

So what's the best way to "store" this information so I can reuse it to get the next pages and how can I do it? 那么“存储”此信息的最佳方法是什么,以便我可以重用它来获取下一页,并且该怎么做?

Many thanks to you all and sorry if this is too newbie question. 非常感谢大家,如果这是一个新手问题,我们深表歉意。

You can use model.addAttribute within controller to add Page or Size . 您可以在控制器内使用model.addAttribute添加PageSize

You can send them there by JavaScript or Form in Thymeleaf when needed. 您可以根据需要通过JavaScriptThymeleaf Form将它们发送到那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM