자바를 사용하고 있습니다.Google App Engine - 이상한 방식으로 데이터 저장 중
<p>Something</p> <p>That</p> <p>�</p> <p>Should.</p> <p>�</p>
<p>I have an interesting question.</p> <p>Why are you like this?</p>
<p>�</p> <p>Aren't you fine?</p>
이 이상한 기호까지 무엇 : 이것은이 저장되는 방식이다
<p>Something</p>\n<p>That</p>\n<p> </p>\n<p>Should.</p>\n<p> </p>\n
<p>I have an interesting question.</p>\n<p>Why are you like this?</p>\n
<p> </p>\n<p>Aren't you fine?</p>
:이 데이터 저장소에 삽입됩니다 순수한 데이터입니까? 이것은 로컬 dev_appserver가 아닌 라이브에서만 발생합니다. 나는 작은 item.isFormField()
마법 실제 내용을 얻기 위해 그렇게하고, 문자열을 구성 할 수 있도록
String content = ""; // this is where the data is stored
try {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(request);
while(iter.hasNext()) {
FileItemStream item = iter.next();
InputStream stream = item.openStream();
if(item.isFormField()) {
String fieldName = item.getFieldName();
String fieldValue = new String(IOUtils.toByteArray(stream), "utf-8");
LOG.info("Got a form field: " +fieldName+" with value: "+fieldValue);
// assigning the value
if(fieldName.equals("content")) content = fieldValue;
} else {
...
}
}
} catch (FileUploadException e){
}
...
// insert it in datastore
Recipe recipe = new Recipe(user.getKey(), title, new Text(content), new Text(ingredients), tagsAsStrings);
pm.makePersistent(recipe);
그것은 multipart/form-data
양식의 :
편집 여기에 데이터를 삽입하는 코드입니다. 이상한 인코딩 문제가 원인 일 수 있습니까? 확실하지 않다. content
이후
<%=recipe.getContent().getValue()%>
유형의 텍스트 (응용 프로그램 엔진 타입) 나는 실제 결과를 얻기 위해 .getValue()
를 사용하다 :
\ n은 새 행의 표시 자입니다. 그게 당신이 말하는 겁니까? –
인코딩 문제가 99 %입니다. 코드에서 인코딩을 어떻게 다루고 있습니까? 관련 스 니펫을 게시 할 수 있습니까? – systempuntoout
@systempuntoout : 나는 그것을 다루지 않을 것이다. 내가해야 할 특별한 것이 있습니까? –