我到处搜索但是没有找到解决我问题的方法。 我有以下课程:
class Output{
private List<Response> response=new ArrayList<Response>();
public List<Response> getResponse(){
return this.response;}
public void setResponse(final List<Response> response) {
this.response= response;}
}
class Response
private String amount
public String getAmount(){
return this.amount;}
public void setAmount(String amount) {
this.amount = amount;}
}
我有另一组课程
class Otherlist{
private List<Otherresponse> otherresponse=new ArrayList<Otherresponse>();
public List<Otherresponse> getOtherResponse(){
return this.otherresponse;}
public void setOtherResponse(final List<Otherresponse> otherresponse) {
this.otherresponse= otherresponse;}
}
class Otherresponse{
private String iamount
public String getIamount() {
return iamount;}
public void setIamount(final String iamount) {
this.iamount = iamount;}
}
映射xml看起来像 DozzerMapping.xml
<mapping>
<class-a>Response</class-a>
<class-b>Otherresponse</class-b>
<field>
<a>amount</a>
<b>iamount</b>
</field>
</mapping>
我有一个控制器类,我收到json响应作为对象列表。但是我需要将收到的对象列表(Response类)映射到前端(Otherresponse类)。我无法映射从Response到Otherresponse的值。打印其他响应对象时,我得到null。映射的控制器类如下:
public class Controller{
Otherresponse otherresponse= this.dozerMapper.map(response.getBody(), Otherresponse.class)
}