在CurrencyInstance.properties = params之后未设置Grails currencyInstance.properties

时间:2013-12-07 19:00:36

标签: grails grails-controller

我正在使用Grails 2.3.3

在CurrencyController中。之后

currencyInstance.properties = params

currencyInstance.properties不会更改。

但是如果我设置了

,currencyInstance.properties就会改变
currencyInstance.code = params.code
currencyInstance.name = params.name

这是我的参数:

println "Here is params: $params"

==> Here is params: [id:34, name:Australian dollar 1, code:AUD, version:4]

和域名

class Currency {

    String code;
    String name;

    static constraints = {
        code blank : false;
        code unique: true;
    }

    static mapping = {
    }

}

1 个答案:

答案 0 :(得分:0)

我发现错误是我失败了 1 - 如果我将http PUT发送到http://localhost:8080/test_parmas/api/currencies/9?name=zzzzzz并设置Header Content-Type = application / json但是将空体数据发送到服务器。
OR
2 - 如果我将HTTP PUT发送到http://localhost:8080/test_parmas/api/currencies/9并设置Header Content-Type = application / json和body-data(具有id = 9)

{
"id":9
"name":"Australian dollar 111"
}

如果是的话 1 - 如果我将http PUT发送到http://localhost:8080/test_parmas/api/currencies/9?name=zzzzzz

2 - 如果我将HTTP PUT发送到http://localhost:8080/test_parmas/api/currencies/9并设置Header Content-Type = application / json和body-data

{
"name":"Australian dollar 111"
}