我在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')")
^
这是代码......
BuildConfig
//...
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
}
提前致谢!
答案 0 :(得分:2)
java.util.List
是一个接口,无法用作 Command Object ,请尝试此操作:
使用
中的列表创建一个命令对象import grails.validation.Validateable
@Validateable
class SearchListCommand extends SearchCommand {
List values
}
并使用getAssociatedToEntities
操作
def getAssociatedToEntities(SearchListCommand listCommand) {
//code omitted...
}
答案 1 :(得分:0)
将其包装在列表中:@Secured("hasAnyRole(['READ__USER', 'READ__PROFILE'])")