提问人:B.Balamanigandan 提问时间:9/22/2022 最后编辑:B.Balamanigandan 更新时间:9/24/2022 访问量:69
使用 ajax POST 方法将 String List<List<String>> 的嵌套列表传递给 Java SE 11
Pass Nested List of String List<List<String>> to Java SE 11 using ajax POST method
问:
我有一个包含类型属性的模型,我试图从它收到的邮递员传递一个模型,而不是实际数据。List<List<String>>
null
技术:JAVA SE 11 - Spring Book Maven 应用程序 - AWS Lambda
示例模型
public class KeyParamInfo {
private String key;
private List<List<String>> referenceData;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public List<List<String>> getReferenceData() {
return referenceData;
}
public void setReferenceData(List<List<String>> referenceData) {
this.referenceData = referenceData;
}
}
PostMan 中相应的身体数据是
{
"key":"PROG",
"referenceData":[
[
"JAVA",
"KOTLIN"
],
[
"HTML",
"JS"
]
]
}
Java代码:
public class SampleApplication implements RequestHandler<KeyParamInfo, List<String>> {
public List<String> handleRequest(KeyParamInfo input, Context context) {
List<String> response = new ArrayList<String>();
try {
if(input != null) {
if(input.getReferenceData() != null) {
response.add("Reference Data Received");
}
else if(input.getKey() != null && !input.getKey().equals("")) {
response.add("Data Received with key " + input..getKey());
}
else {
response.add("Empty Data Object");
}
} else {
response.add("Invalid Data");
}
} catch (Exception e) {
response.add("Exception occured in Main method - " + e.getMessage());
}
return response;
}
}
以下是从上述代码返回的响应["Data Received with key PROG"]
AWS Lambda 文档:https://docs.aws.amazon.com/lambda/index.html
在应用程序中,接收值而不是上面的嵌套列表。请协助如何将请求的嵌套列表传递到 JAVA 中。referenceData
null
答: 暂无答案
评论