处理post的json请求主体丢失问题

This commit is contained in:
wanggeng 2021-09-30 11:55:08 +08:00
parent 4342b6ab30
commit e8bdc1ace5
4 changed files with 20 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import org.springframework.context.annotation.Configuration;
public class MiniappProperties {
private Boolean active;
private String apiUrl;
private String authorizeUrl;
private String grantType;
private String appKey;
@ -31,6 +32,14 @@ public class MiniappProperties {
this.active = active;
}
public String getApiUrl() {
return apiUrl == null ? "" : apiUrl.trim();
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getAuthorizeUrl() {
return authorizeUrl == null ? "" : authorizeUrl;
}

View File

@ -19,6 +19,7 @@ public class OfficialAccountProperties {
private Boolean apiCrossOrigin;
private Boolean activate;
private String apiUrl;
private OfficialAccountAuthorizeProperties authorize;
private String accessTokenUrl;
private String appId;
@ -42,6 +43,14 @@ public class OfficialAccountProperties {
this.activate = activate;
}
public String getApiUrl() {
return apiUrl == null ? "" : apiUrl.trim();
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public OfficialAccountAuthorizeProperties getAuthorize() {
return authorize;
}

View File

@ -81,7 +81,7 @@ public class RestRemoteHandler implements InvocationHandler {
RemotePostMethod postMethod = method.getAnnotation(RemotePostMethod.class);
uri = postMethod.value();
formVariableParams = getFormVariableParams(method.getParameters(), args);
if (formVariableParams == null) {
if (formVariableParams.isEmpty()) {
requestBody = getRequestBody(method.getParameters(), args);
}
} else if (method.isAnnotationPresent(RemotePutMethod.class)) {

View File

@ -49,7 +49,7 @@ public class RestRemoteRequest {
result = delete(remoteUri, headers);
} else if (RequestMethod.POST.equals(requestMethod)) {
// form表单优先
if (formVariableParams != null) {
if (!formVariableParams.isEmpty()) {
result = post(remoteUri, headers, formVariableParams);
} else {
result = post(remoteUri, headers, jsonBody);