从 PHP 应用程序调用 grails 控制器,它以 JSON 格式发送数据。
当我打印参数时
println params
哪个打印
[{"courseCategory":null,"courseId":null,"show":null,
"rows":6,"trainers":null,"courses":null,"cities":null,
"fromDate":null,"toDate":null,"pageType":"HOME","deal":null}:,
action:getTrainingsAsJson,
controller:publicTraining]
当我做
println params.rows
println params.pageType
哪个打印null
我试过了
def jsonObject = request.JSON // prints [:]
我也试过JsonSlurper
def slurper = new JsonSlurper()
def result = slurper.parseText(params)
这给出了错误
No signature of method: groovy.json.JsonSlurper.parseText() is applicable for argument types: (org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap)
如何将其转换为检索参数值?
或者有什么方法可以将其转换为地图,以便我可以轻松访问参数?