【发布时间】:2019-09-13 14:24:59
【问题描述】:
我有一个Switch,其中包含13 个case,每个案例执行不同的sql 请求。我在ArrayList<HashMap<String, String>> 中得到了结果。这个结果应该用 angular 显示,现在我正在使用这个 this.respTest = JSON.stringify(response); 所以它显示了 "key":"value" 的列表。
我的问题是因为每个请求都会给我不同的数据库字段和值,所以我想合并一些字段。 我创建了这个类:
public class DataCollect {
private String type ;
private String entity ;
private String modPar ;
private String dateModif ;
private String numVersion ;
public DataCollect(String type, String entity, String modPar, String dateModif, String numVersion) {
this.type = type;
this.entity = entity;
this.modPar = modPar;
this.dateModif = dateModif;
this.numVersion = numVersion;
}
public DataCollect() {
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getEntity() {
return entity;
}
public void setEntity(String entity) {
this.entity = entity;
}
public String getModPar() {
return modPar;
}
public void setModPar(String modPar) {
this.modPar = modPar;
}
public String getDateModif() {
return dateModif;
}
public void setDateModif(String dateModif) {
this.dateModif = dateModif;
}
public String getNumVersion() {
return numVersion;
}
public void setNumVersion(String numVersion) {
this.numVersion = numVersion;
} }
在这个类中,我应该将字段的名称影响到我创建的变量,并作为返回一个带有我从数据库中提取的数据的 hashmap 的数组列表。 我的意思是我曾经返回例如 "field-name":"value" ,我想返回 "type":"value","entity":"value" ..etc
我在后端使用 springboot,在前端使用 angular 5。 任何帮助将不胜感激。
【问题讨论】:
-
是您将 SQL 查询 [resultSet] 的结果转换为 List
...?? 的问题 -
@ShubhamMaheshwari 不,它更复杂,我已经在数组列表中得到了结果,但我不想制作一个特定/个性化的列表,而不是将结果显示为“字段- name":"value" ,我将其显示为我已经创建的变量之一,例如 "type":"value"
标签: java spring-boot arraylist hashmap