public ResponseEntity<?> postData(some request) {
Map<String, Object> data = someRepository.getDataByID(someId);
// data that you get from sql query, note that you have to map it though
// in response type of sql query of whatever java tool you are using for getting the sql data
System.out.println("The fields are: " + data.keySet());
for(String fieldKey: data) {
System.out.println("key is " + key);
System.out.println("value is " + data.get(key));
}
... your logic
return new ResponseEntity(data, HttpStatus.OK);
}
1条答案
按热度按时间ubbxdtey1#
如果允许的话,您可以使用hashmap来存储查询结果
通过这种方式,您可以获得总字段的长度或执行map提供的其他操作。
下面是示例代码