grails - 在Grails中的json View 中访问 Controller 参数

标签 grails grails3 json-view

使用json View 的 Controller 将调用与呈现域时调用的 Controller 方法相对应的json View 。

但是我想将 Controller 参数除传递给域外,还传递给json View ,以自定义域的呈现方式。

使用此功能的典型示例是以简短或详细的方式显示在索引端点中呈现的域。

如何使 Controller 参数传递给json View ?

最佳答案

How can I make pass the controller params to the json view?



您无需做任何事情。您可以在JSON View 中引用params变量。我们以这种方式提供直接访问。

有关更多信息,请参见http://views.grails.org/latest/的“访问请求”部分。

关于grails - 在Grails中的json View 中访问 Controller 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53061046/

相关文章:

json - 有没有办法在 Postman 中折叠所有 json 字段

grails - 动态默认属性 grails

Grails 3 集成规范具有奇怪的事务行为

grails - Grails JSON渲染器未公开拦截器模型

java - Grails 脚手架 View 中没有水平滚动

grails - 如何在Grails 3的编辑 View 中修改ID列的值?

java - 在 Spring MVC 4 + jackson 2.5 中使用 @JsonView

grails - GSP 与 Grails 中的 Controller

grails - 如何从 View 中确定 Controller /函数调用者

Grails Action 参数日期绑定(bind)