Angular击中休息API并获得400

时间:2017-12-22 07:18:30

标签: java angularjs

我正在点击角度请求,但它没有达到服务错误400,404,有时内容类型无法访问

角度代码

$scope.addOperator = function() {
    var req = {
        method : 'POST',
        url : config.apiUrl + "/addoperator",

        data: $scope.fields
    }
    $http(req).then(function successCallback(data) {

                $scope.resp_res = true;
                $scope.MSG = "Operator is created successfully";
                return;

    }, function errorCallback(response) {
            console.log(response.statusText);
        });
        $scope.MSG = "Operator is created successfully";
};

我的服务代码在这里

@CrossOrigin(allowedHeaders = { "Content-Type" })
@RequestMapping(value = "addoperator",method=RequestMethod.POST)
public ResponseEntity<?> addOperator(@RequestBody AddOperatorBean addOperatorBean)
{
    logger.info("call add operator!!! ");

    AddOperator addOperator = new AddOperator();
    addOperator.setName(addOperatorBean.getName());
    addOperator.setEmail(addOperatorBean.getEmail());
    addOperator.setMobile(addOperatorBean.getMobile());
    addOperator.setPin(addOperatorBean.getPin());
    addOperator.setLotid(addOperatorBean.getLotid());
    addOperator.setRoleId(addOperatorBean.getRoleId());
//  addOperator.setStatus(addOperatorBean.isStatus());
    addOperator.setStatus(false);
    addOperator.setCreatedAt(new Timestamp(new Date().getTime()));
    checkUserService.addOperator(addOperator);
    return new ResponseEntity<>(HttpStatus.OK);
}

提前感谢您的帮助

0 个答案:

没有答案