我很难在RestTemplate实体中以UTF-8编码我的multipart / form-data。我不知道我做错了什么。下面我发布了我的代码
function onFormSubmit() {
var form = FormApp.getActiveForm();
var email_address = form.getResponses()[0].getRespondentEmail();
var date = new Date("insert-date-here");
var event = CalendarApp.getCalendarById("calender-id-here").getEventsForDay(date);
event[0].addGuest(email_address);
var guests = event[0].getGuestList()[0].getEmail();
var status = event[0].setMyStatus(CalendarApp.GuestStatus.YES);
}
当我将任何波兰字母插入文本参数时,例如:“ł” 其余模板将其作为“?”发送。你可以在下面看到它,实际上身体看起来像这样,“ł”被转换成“?”:
LinkedMultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("text", text);
map.add("id", id);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set("Content-Type","multipart/form-data;charset=UTF-8");
HttpEntity<LinkedMultiValueMap<String, String>> entity = new HttpEntity<>(map, httpHeaders);
ListenableFuture<ResponseEntity<String>> response = asyncRestOperations
.postForEntity(url, entity, String.class);
我不知道为什么它不能正常工作。如何将默认的ISO-8859-1编码更改为UTF-8?任何帮助非常感谢!
干杯。
解决方案:
我稍微修改了我的AsyncRestTemplate,它不再丢失UTF-8编码。我的工作代码:
Content-Disposition: form-data; name="text"
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 1
?