한글 인코딩 중 빨간글씨로 칠한 key, value 부분을 큰따옴표로 감싸지 않아 오류가 났다.
보내고 싶은 쿼리: &searchQuery={"MBR_FLNM":"강"}&curPage=1
완성된 쿼리: &searchQuery=%7B%22MBR_FLNM%22%3A%22%EA%B0%95%22%7D&curPage=1
// searchQuery 작성
String searchQuery = "";
String sFindNm = param.get("sFindNm").toString();
if(!"".equals(sFindNm)){
try {
searchQuery = URLEncoder.encode("{\"MBR_FLNM\":\"" + sFindNm + "\"}", "UTF-8");
} catch (UnsupportedEncodingException e2) {
log.error(e2);
}
}
// curPage 작성
int curPage = 1;
try {
curPage = Integer.parseInt(param.get("sPageNo").toString());
} catch (Exception e) {
log.error("curPage Exception 발생");
curPage = 1;
}
URL url = null;
HttpURLConnection connection = null;
try {
url = new URL(apiURL + "?certCode=" + certCode + "&searchQuery=" + searchQuery + "&curPage=" + curPage);
connection = (HttpURLConnection) url.openConnection();
} catch (MalformedURLException e) {
} catch (IOException e) {
log.error(e);
}
'old' 카테고리의 다른 글
setConnectTimeout, setReadTimeout (0) | 2023.05.10 |
---|---|
[JAVA] JSON 형식 String to Map 형변환 (0) | 2023.03.30 |
[eclipse] 디버깅 단축키 (0) | 2023.03.29 |
TPC(Two Phase Commit) 이기종 데이터베이스 분산 트랜잭션 구현 (Java Atomikos) (0) | 2023.03.22 |
2. geoserver 타일 레이어 (캐시된 레이어) (0) | 2022.11.09 |