标签:name int time bottom number err span 后端 flex
var loanOrderNumber = $routeParams.loanOrderNumber;
$scope.saveButton = true;
$http.get("/test/business/order/viewDetail",{
params : {
‘loanOrderNbr‘ : loanOrderNbr
}
}).success(function(request,status){
//
}).error(function (data, status) {
//
});
//查看数据
@RequestMapping(value = "/viewDetail")
@ResponseBody
public AtResponse detail(@RequestParam(name = "loadOrderNbr", required = true) String loadOrderNbr) {
Map<String, Object> params = new HashMap<String, Object>();
AtResponse<TxnAcct> resp = new AtResponse(System.currentTimeMillis());
//.....
return resp;
}
:8080/test/business/order/viewDetail?loanOrderNbr=201706091042631 Failed to load resource: the server responded with a status of 400 (Bad Request)
当时以为是前面angularjs代码写得有问题,然而仔细对比其他功能的写法,发现没有什么区别,只是传的参数不一样而矣,非常迷惑,不解。后台也不报错(没有输出spring日志),然后将请求链接直接在浏览器中访问:
http://localhost:9770/test/business/order/viewDetail?loanOrderNbr=201706091042631
页面提示如下错误信息:
Required String parameter ‘loanOrderNbr’ is not present
发现是前端传的参数名与后端代码定义的参数名不一致导致的,囧:
前端参数是:loanOrderNbr
后端参数是:loadOrderNbr
将后台代码修改为:
@RequestMapping(value = "/viewDetail")
@ResponseBody
public ResponseBase addQuestion(@RequestBody Map<String,Object> params){
String loanOrderNbr = params.get("loanOrderNbr").toString();
}
Required String parameter is not present
标签:name int time bottom number err span 后端 flex
原文地址:https://www.cnblogs.com/williamjie/p/9200634.html