jsoup 으로 json, xml 결과 페이지를 호출하면
Unhandled content type. Must be text/*, application/xml, or application/*+xml 
오류가 발생함
 
해결방법은
.ignoreContentType(true)  설정하면 됨
 
Jsoup.connect("/test.json")
  	.ignoreContentType(true)
  	.method(Method.GET)
  	.execute();

혹은 header에 ContentType 을 json이나 xml 로 지정해도 될 듯.

 

끝.

반응형

 

1. json-simple  의존성 추가

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1</version>
</dependency>
 

 

2.  샘플 코드
String jsonText = "{ \"test\" : \"1234\" }";
JSONParser parser = new JSONParser();
Object obj = parser.parse(jsonText);
JSONObject jsonObj = (JSONObject) obj;
String testValue = jsonObj.get("test").toString();
System.out.println("testValue : " + testValue);
// 결과
testValue : 1234

 

반응형
try ~ 오류가 catch가 안 된다.
 
var xReq = new XMLHttpRequest();
xReq.onreadystatechange = function() {
   console.log(xReq.readyState);
  console.log(xReq.status);
}
xReq.open("POST", "http://localhost:9999/test", true);
xReq.send(post);
 
서버 (http://localhost:9999/) 실행 중이지 않은 경우
xReq.send(post); 에서
net::ERR_CONNECTION_REFUSED 오류가 발생한다.
 
그래서, 오류 발생시 처리를 위해...
 
try {
        xReq.send(post);
} catch(err) {
        alert('오류가 발생하였습니다. ');
//
}
 
이런 식으로 try ~ catch ~ 해보았으나 catch 가 안된다.
 
이럴 땐, 아래 처럼 하면 오류시 처리를 할 수 있다.
 
xReq.onerror = function () {
     alert('오류가 발생하였습니다.');
      //
};
 
 
 
끝.
반응형
로컬 테스트시 오류 발생
원인유추
  1. 권한문제
  2. 타임존 인식문제
 
  1. 은 아니었고 왜냐면 툴(workbench)로 잘 접속된다. telnet 해봐도 연결 잘되고
 
검색하다보니,  아래 글을 발견
타임존을 아시아/서울로 설정하니 해결됨.
 
 
mysql-connector-java 5.1.X 버전 이후로 KST 를 인식못하는 오류가 있다.
 
 
또는, 기존 운영중인 서버라면 아래와 같이 Asia/Seoul 로 설정해 준다.

 

타임존을 UTC 또는 Asia/Seoul 로 지정해야 정상적으로 연결된다.또는 커넥터를 낮은 버전으로 해도 된다.
반응형

 

의존성 추가한 라이브러리가 안 받아지는 오류가 발생함.
라이브러리가 없으니 다양한 오류가 발생함.
아무리 clean 하고 maven update project 해도 해결이 안됨.
프로젝트를 새로 받아서 해도 안됨.
pom.xml repository를 변경해도 암됨.
원인은 repository 캐시 때문이었음
 
아티팩트 (또는 전체 로컬 저장소)를 c:\Users\<username>\.m2\repository  직접 삭제하고
다시 maven install해보니 제대로 받아온다.
 
끝.

 

반응형

+ Recent posts