有很多这样的问题,但没有任何帮助。 我试图从这样的rest api得到回应:
private void createActorInstance(AbstractActorDTO actor)
{
HttpHeaders headers = new HttpHeaders();
headers.add(AUTHORIZATION_HEADER_NAME, BASIC_AUTHORIZATION_HEADER_PREFIX + cmsRestApiCreds);
HttpEntity<AbstractActorDTO> postRequest = new HttpEntity<>(actor, headers);
ResponseEntity<String> postResponse = restTemplate.exchange(cmsRestApiUrl+"/actors", HttpMethod.POST,
postRequest, String.class);
}
我正在调用这个函数:
PersonActorDTO actor = new PersonActorDTO();
createActorInstance(actor);
提到AbstractActorDTO类是PersonActorDTO的超类。
摘要DTO:
public abstract class AbstractActorDTO extends AbstractDTO {
@DTOProperty(
entityProperty = "actorInstance.actor.actorCategory"
)
private String actorCategoryID;
@DTOProperty(
entityProperty = "actorInstance.scope"
)
private String scopeID;
public AbstractActorDTO() {
}
public String getActorCategoryID() {
return this.actorCategoryID;
}
public void setActorCategoryID(String actorCategoryID) {
this.actorCategoryID = actorCategoryID;
}
public String getScopeID() {
return this.scopeID;
}
public void setScopeID(String scopeID) {
this.scopeID = scopeID;
}
}
PersonActorDTO:
public class PersonActorDTO extends AbstractActorCreateDTO {
@DTOProperty(
entityProperty = "actorInstance.aliases"
)
private List<PersonAliasDTO> aliases = new ArrayList();
@DTOProperty
private String firstName;
@DTOProperty
private String middleName;
@DTOProperty
private String lastName;
@DTOProperty
private String prefix;
@DTOProperty
private String suffix;
public PersonActorDTO() {
}
public List<PersonAliasDTO> getAliases() {
return this.aliases;
}
public void setAliases(List<PersonAliasDTO> aliases) {
this.aliases = aliases;
}
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getMiddleName() {
return this.middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getPrefix() {
return this.prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getSuffix() {
return this.suffix;
}
public void setSuffix(String suffix) {
this.suffix = suffix;
}
}
谢谢。