错误请求400 - @ RequestBody

时间:2015-10-08 15:17:18

标签: json spring-mvc

我正在尝试发送JSON:

{"source": "CED:100973626887874,CED:77148046400112,CED:222222222222201"}` 

我的控制器如下:

@RequestMapping(value = "/multipleMember/list", method =RequestMethod.POST)
@ResponseBody
public List<MemberDetail> getMultipleMemberList(
        @RequestBody String memberList) {
    return memberServiceDelegate.getMultipleMemberList(memberList);
}

但是我收到了错误的请求400:客户端发送的请求在语法上是不正确的

2 个答案:

答案 0 :(得分:1)

也许你的json对象需要一个名为memberList的对象

int main() {
    char string[100];
    int i, j;

    printf("\nEnter string: ");
    gets(string);

    if (isalpha(string[0])){                //capitalize the first character in the string if it is a letter
        string[0] = toupper(string[0]);  //copy character to newString

    for (i=1; i <strlen(string); i++){                  
        if (string[i-1] == ' ' && isalnum(string[i]))       //if the character is preceded by a space
            string[i] = toupper(string[i]);        //copy the uppercase of the character to newString
    }
    i=strlen(string);
    while (i){
        int j= i;
        while (j && j!=' ') j--;
        printf("%.*s ", i-j,string+j);
        i=j;
    }
    return 0;
}

答案 1 :(得分:0)

我相信你需要用{}包装你的json,以表明它是一个对象。

{
"source": "CED:100973626887874,CED:77148046400112,CED:222222222222201" 
}