用postman测试,x-www-form-urlencoded成功但raw json类型却错误提示400

前端测试后端成功,但是使用postman测试的时候出现400错误,
如果我用postman body中的raw,格式为json会出400错误
如果换为x-www-form-urlencoded 则成功,请问原因是什么导致的呢?

img

img

这是后端:

@Controller
@RequestMapping(value = "tes/")
public class Tes {
    @RequestMapping(value = "main", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject tes_main(@RequestParam(value="str") String str) {
        System.out.println(str);
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("结果",str);
        return jsonObject;
    }
}

这是前端,前端用ajax测试没有问题

$.ajax({
            type: "post",
            url: "http://localhost:8080/tes_w/tes/main",
            data: {
                str:"测试"
            },
            dataType: "json",
            success: function(data) {
                alert(data.结果);
            },
            error:function (result){
                alert("请求失败");
            }
        });

RequestParam可不支持json数据

你的服务端接口不支持通过raw传递请求参数

这样是对的

img