2017-12-12 3 views

Antwort

1

Sie können Annotation @RequestBody verwenden, um Ihre jsonArray zu erhalten und einen Wrapper, der eine Modellliste hat, Ihre Liste speichern. wie folgt vor:

Modell:

public class Tuple { 
private String key; 
private String value; 
private String description; 
public String getKey() { 
    return key; 
} 
public void setKey(String key) { 
    this.key = key; 
} 
public String getValue() { 
    return value; 
} 
public void setValue(String value) { 
    this.value = value; 
} 
public String getDescription() { 
    return description; 
} 
public void setDescription(String description) { 
    this.description = description; 
} 

public Tuple(String key, String value, String description) { 
    this.key = key; 
    this.value = value; 
    this.description = description; 
} 

}

Wrapper:

public class TupleWrapper{ 
    private List<Tuple> tupleList; 
    public List<Tuple> getTuple() { 
     return tupleList; 
    } 
    public void setTuple(List<Tuple> tuples){ 
     this.tupleList = tuples; 
    } 
} 

Controller:

@RequestMapping(value="/setTuple", method = RequestMethod.POST) 
public ResponseEntity<ResponseStatus> setTuple(@RequestBody TupleWrapper wrapper){ 
    //your logic. 
    return new ResponseEntity<ResponseStatus>(new ResponseStatus<>(STATUS.SUCCESS,"OK",wrapper),HttpStatus.OK); 

} 
Verwandte Themen