HTML과 Java를 사용하여 초보자라고 생각해보십시오. 내 문제를 엿보고 제안 할 수 있다면 고맙겠습니다. 나는 기본적으로 다음 순서로 다음을 시도하고있다 :HTML 결과가 인코딩 됨
을 통해 1) 클래스를 사용하여 자바로 HTTP 요청을 보낸다.
2) 결과 가져 오기. 내가받을 결과는 HTML 형식
3) 실제 결과는 ", ;, :
등 모든 따옴표가 결과에 엔티티 (& quot)로 변환됩니다 (htmlOutput 문자열)
내가 가진 질문은 같은 문자가 포함에 다음과 같은. 인코딩 된 결과를 가져 오지 않으려면 어떻게해야합니까? 엔티티 (& quot)를 포함하지 않는 원래 문자열로 결과를 얻는 좋은 방법이 있습니까? 다음은 내가 사용하는 코드입니다.
int statusCode = HttpStatus.SC_OK;
String scriptOutput = "";
PostMethod runnerMethod = new PostMethod(url);
try {
runnerMethod.setRequestHeader("X-Forwarded-For", LOCAL_MACHINE_IP);
runnerMethod.addParameter("script", serializedScript);
statusCode = client.executeMethod(runnerMethod);
if (statusCode != HttpStatus.SC_OK) {
scriptOutput = "HTTP Post request failed with statusCode" + statusCode +
runnerMethod.getStatusText();
throw new Exception(scriptOutput);
}
String htmlOutput = runnerMethod.getResponseBodyAsString();
scriptOutput = StringUtils.substring(htmlOutput, StringUtils.indexOf(htmlOutput,"Script:") + 8, StringUtils.indexOf(htmlOutput, "<BR/>"));
return scriptOutput;
} catch (IllegalArgumentException e) {
String errMsg = String.format("Error during Background script execution on instance. opId = %s, instanceUrl = %s, HTTP Status Code = %d, Err Message = %s",
opId, instanceUrl, statusCode, e.getMessage());
return errMsg;
}
catch (Exception e)
{
String errMsg = String.format("Error during Background script execution on instance. opId = %s, instanceUrl = %s, HTTP Status Code = %d, Err Message = %s",
opId, instanceUrl, statusCode, e.getMessage());
return errMsg;
}
finally {
runnerMethod.releaseConnection();
}
출력 샘플은 다음입니다 : HTTP 서버에 게시됩니다 무엇
"변환 된"의미가 무엇인지 설명해야합니다. 3)'htmlOutput' 변수에 HTML 엔터티 (" 등)가 없습니까? – pwes
@pwes : 귀하의 제안에 대해 좀 더 명확하게 설명했습니다. 귀하의 질문에 대답하기 위해 htmlOutput에는 HTML 엔터티가 포함되어 있습니다.이 경우에는 & quot; 실제 대신 & quot; 질문이 명확한 경우 알려주십시오. – animageofmine