为Grails 2.3.x的域类上的@Resource结果更改max属性的默认值 [英] Change default for max attribute on results for @Resource on domain classes for Grails 2.3.x

查看:113
本文介绍了为Grails 2.3.x的域类上的@Resource结果更改max属性的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个将域类作为json结果的应用程序。
是否有办法改变结果的默认 max



我正在做的是 http://site/domain-class.json ,我只是得到10个结果。我想避免创建所有链接,如 http://site/domain-class.json?max = 999



<有没有办法将这个默认值增加到不同的地方?我试图在没有任何运气的情况下搜索源代码。 :

解决方案

这不是使用@Resource批注可配置的。



然而,您始终可以为您的域生成控制器,并修改list()方法的实现以具有不同的默认最大值。



这里是控制器它支持一个标有@Resource接口标注的域,正如你所看到的,默认的最大值不是由任何配置值驱动的。



使用 grails generate-controller 将允许您在生成的控制器中为您的域更改该值。


I'm working on an app that serves domain classes as json results. Is there a way to change the default max for the results?

What I'm doing is http://site/domain-class.json and I'm only getting 10 results. I want to avoid creating all the links as http://site/domain-class.json?max=999

Is there a way to increase that default value to something different? I tried searching the source code without any luck. :(

解决方案

That's not configurable using the @Resource annotation.

However, you can always generate your controller for your domain and modify the implementation of the list() method to have a different default maximum.

Here is the controller which backs a domain which is marked with the @Resource interface annotation. As you can see the default maximum value is not driven by any configuration value.

Using grails generate-controller for your domain will allow you to change that value in the generated controller for your domain.

这篇关于为Grails 2.3.x的域类上的@Resource结果更改max属性的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆