카테고리 없음
URI를 사용하여 addParameter를 사용하면 자동 인코딩이 된다
DRAGON.Q
2018. 9. 13. 16:59
RestTempate.exchange를 사용할 때 Apache에서 제공해주는 URIBuilder를 사용하여 add 파람을 하게 되면 자동으로 인코딩을 해준다.
이걸 모르고 addParamter를 호출 할 때 URI.encoding("value", "UTF-8")를 하니까 검색이 잘 되지 않았다.
if (this.encodedQuery != null) {
sb.append("?").append(this.encodedQuery);
} else if (this.queryParams != null) {
sb.append("?").append(encodeUrlForm(this.queryParams));
} else if (this.query != null) {
sb.append("?").append(encodeUric(this.query));
}
private String encodeUrlForm(final List<NameValuePair> params) {
return URLEncodedUtils.format(params, Consts.UTF_8);
}