我已成功设置我的Grails应用程序来验证用户。如何使用@Secured闭包时获得控制器方法参数?
我映射使用网址参数控制方法的参数,在我UrlMappings.groovy:
"/$source/owner/$ownerId/show"(controller:"myController", action: "show", method: "GET")
我如何得到我的@Secured关闭$源和值$ OWNERID?
我控制器的方法是这样的:
@Secured(closure = {
//null
def testSource = params.source
//also null
def testOwnerId = params.ownerId
//null
def owner = request.ownerId
//null
def owner2 = request.getParameter('ownerId')
//contains only query string params
def grailsParams = request['org.codehaus.groovy.grails.WEB_REQUEST']?.params
return true
})
def show(String source, String ownerId) {
...
}
我如何获得这些价值?我在做什么错,在这里?
我认为,这一职位将提供一个解决方案,但鉴于那里的答案并没有为我工作:
我使用下面的Grails和插件版本:
grails 2.5.1
compile ":spring-security-core:2.0-RC5"
compile ":spring-security-rest:1.5.3", {
excludes 'com.fasterxml.jackson.core:jackson-databind:'
}
如果你简单地执行'def owner = request.ownerId',会发生什么?那也是空的? – Gregg
@Gregg谢谢你的回复!但是这也返回null。 – RMorrisey
试试'println params'看看它们是否全部通过。如果是这样,你可以从数组中找到值。 –