我正在尝试用我的Xpage读取由 out.writeBytes 创建的java生成的JSON流。我可以获取getServerPort和其他数据(在下面的代码中列出),但是当我尝试使用BufferedReader或ServletInputStream读取上下文时,我正在发现错误。 任何人都知道在Xpage上读取流内容的简单方法吗? readLine 方法返回null。
var exCon = facesContext.getExternalContext()
var httpRequest:javax.faces.contex.ExternalContext =exCon.getRequest();
print("CallCenter getContext "+String(exCon.getContext()))
print("CallCenter ContentType "+String(httpRequest.getContentType()))
print("CallCenter ContentLength"+String(httpRequest.getContentLength()))
print("CallCenter RemoteAddr "+String(httpRequest.getRemoteAddr() ))
print("CallCenter ServerPort "+String(httpRequest.getServerPort()))
facesContext.responseComplete();
// ONE OF METHODS I've TRIED =============
var stringBuffer:java.lang.StringBuffer = new java.lang.StringBuffer(80);
var line = null;
var reader:java.io.BufferedReader = httpRequest.getReader();
while ((line = reader.readLine()) != null)
{
stringBuffer.append(line);
stringBuffer.append("\n");
}
print("Buffer "+stringBuffer.toString());
// ============================
} catch(e) {
_dump(e);
FDF
答案 0 :(得分:1)
只能有一个:流或读者。而不是getReader()使用新的InputStreamReader(in);指向上下文的输入流