AWS lambda java请求POJO属性为null

时间:2018-03-27 18:38:33

标签: java amazon-web-services aws-lambda

我只是在java中创建一个处理程序,它接受一个名为ProductsModel的POJO。

public ProductsResponseObject handleRequest(ProductsRequestObject productsRequestObject, Context arg1) {

    ProductsResponseObject respObj = null;
    ProductsService productsService = new ProductsService();
    arg1.getLogger().log("inside ProductsHandler.handleRequest with reqtype " + productsRequestObject.getReqType());
    switch (productsRequestObject.getReqType()) {
        case 0:
            respObj = productsService.addProduct(productsRequestObject);
            break;
        case 1:
            respObj = productsService.updateProduct(productsRequestObject);
            break;
        default:
            break;
    }
    return respObj;
}

但是在处理程序方法中,request,reqType和productModel的属性为null。不确定吗?

请求POJO:

public class ProductsRequestObject {
private int reqType;
private ProductsModel productsModel;

public int getReqType() {
    return reqType;
}

public void setReqType(int reqType) {
    this.reqType = reqType;
}

public ProductsModel getProductsModel() {
    return productsModel;
}

public void setProductsModel(ProductsModel productsModel) {
    this.productsModel = productsModel;
}

}

模型POJO:

public class ProductsModel {

private String id;
private String dealerMobNumber;
private String name;
private String description;
private String price;

@DynamoDBHashKey(attributeName = "Id")
public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getDealerMobNumber() {
    return dealerMobNumber;
}

public void setDealerMobNumber(String dealerMobNumber) {
    this.dealerMobNumber = dealerMobNumber;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public String getPrice() {
    return price;
}

public void setPrice(String price) {
    this.price = price;
}

0 个答案:

没有答案