2

私はGrailsを初めて使用するので、これはばかげているかもしれません....しかし、Grails RESTを使用してGrailsのjqueryクライアントからjsonオブジェクトを取得しようとしていますが、nullになっています。小さな不具合かもしれませんが、テストしたい最初のいくつかのデータフローの障害として作成されました

私のjquery呼び出し:

var jsonObjects = [{name: "IPAD", input: "IPAD", program: "IPAD", destination: "IPAD",    
priority: "IPAD", userData: "IPAD", email: "IPAD", webCallBackURL: "IPAD", copyToLocal:    
"IPAD", scriptPreProcess: "IPAD", deleteSource: "IPAD", moveToSource: "IPAD",    
scriptPostProcess: "IPAD", inputImage: "IPAD", leftImage: "IPAD", topImage: "IPAD", 
opacityImage: "IPAD", bImageAdAvBlanking: "IPAD"}] 

$.ajax({ 
    type: "POST", 
    url: 'http://localhost:8080/Medusa/jobControlREST/save', 
    data: {ipad: JSON.stringify(jsonObjects)}, 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    beforeSend: function(x) { 
        if (x && x.overrideMimeType) { 
            x.overrideMimeType("application/json;charset=UTF-8?"); 
        } 
    },
    success: function() { 
        alert('hi'); 
    } 
}); 

私の聖杯:

def save = { 
    def jsonString = params['ipad'] //returns null 
    def json = JSON.parse(jsonString) // returns null obviously 
    println "this is POST call" +json // gets printed but json is null...sign ( 
} 

urlmapping: 
    "/$controller/$action?/$id?"(parseRequest:true) {
        constraints { 
            action = [GET:"index", POST:"save", PUT:"update", DELETE:"remove"] 
        }
    }
4

1 に答える 1