简体   繁体   English

Grails命令对象范围

[英]Grails Command Object Scope

| | Grails Version: 3.0.7 | Grails版本:3.0.7 | Groovy Version: 2.4.4 | Groovy版本:2.4.4 | JVM Version: 1.8.0_60 JVM版本:1.8.0_60

We have a controller using a command object : 我们有一个使用命令对象的控制器:

def search(SearchCommand command) {

}

The command object handles the data binding and form validation. 命令对象处理数据绑定和表单验证。 My question is, what would be the recommended approach to retain the data in the command object between non consecutive calls. 我的问题是,在非连续调用之间将数据保留在命令对象中的推荐方法是什么?

The command object in question holds a good number of parameters used in a complex search and the reason to retain the data is to repopulate the search form each time the user returns to the search form (which may be any number of subsequent requests later). 有问题的命令对象拥有在复杂搜索中使用的大量参数,并且保留数据的原因是每次用户返回搜索表单时都会重新填充搜索表单(以后可能有任意数量的后续请求)。

Any recommendations greatly appreciated. 任何建议,不胜感激。

Either

  • put your command object into the session : 将命令对象放入session
  • or some ConcurrentHashMap -like cache ConcurrentHashMap的缓存
  • or persist it in your DB 或将其保留在您的数据库中

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

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