gpt4 book ai didi

grails - [X] 中的 [getAssociatedToEntities] 操作接受 [java.util.List] 类型的参数

转载 作者:行者123 更新时间:2023-12-02 14:29:38 25 4
gpt4 key购买 nike

语境

我在 Grails 2.4.4 中有一个项目,使用 Spring Security Rest Plugin 1.5.4 for Grails连同 Spring Security Core 2.0.0我得到了这个警告 :

Warning |
The [getAssociatedToEntities] action in [security.UserController] accepts a parameter of type [java.util.List]. Interface types and abstract class types are not supported as command objects. This parameter will be ignored.

@Secured("hasAnyRole('READ__USER', 'READ__PROFILE')")
^

这是代码...

构建配置
//...
compile "org.grails.plugins:spring-security-core:2.0.0"
compile "org.grails.plugins:spring-security-rest:1.5.4"
//...

UserController(警告来自的代码!)
@Secured("hasAnyRole('READ__USER', 'READ__PROFILE')")
def getAssociatedToEntities(List<Long> e, SearchCommand cmd){
//code omitted
}

问题:我怎样才能摆脱这个警告?

提前致谢!

最佳答案

java.util.List 是一个不能用作 Command Object 的接口(interface),试试这个:

创建一个包含列表的命令对象

import grails.validation.Validateable

@Validateable
class SearchListCommand extends SearchCommand {
List values
}

并将列表的声明替换为 getAssociatedToEntities 中的命令对象行动
def getAssociatedToEntities(SearchListCommand listCommand) { 
//code omitted...
}

关于grails - [X] 中的 [getAssociatedToEntities] 操作接受 [java.util.List] 类型的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43900143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com