Spring portlet JSP,制作ajax请求并在控制器中尝试获取jsp页面,以便我可以传递和生成pdf输出。Spring portlet以字符串形式获得jsp响应
但问题是没有得到任何字符串数据,但HTML内容jsp页面上的返回请检查代码follwoing
@Controller("exportSummaryController")
@RequestMapping(value = "VIEW")
public class ExportSummaryController implements PortletConfigAware {
@ResourceMapping("exportAccRequest")
public void accountRollupAction(@RequestParam("accNum") String accNum,
@RequestParam("sourceId") String sourceId, @RequestParam("serviceId") String serviceId,
@RequestParam("summaryExport") String strExport, ResourceRequest request, ResourceResponse response) throws Exception {
//processing data
ResourceResponseWrapper responseWrapper = new ResourceResponseWrapper(response) {
private final StringWriter sw = new StringWriter();
@Override
public PrintWriter getWriter() throws IOException {
return new PrintWriter(sw);
}
@Override
public OutputStream getPortletOutputStream() throws IOException {
return(new StringOutputStream(sw));
}
@Override
public String toString() {
return sw.toString();
}
};
portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/jsp/account_summary.jsp").include(request, responseWrapper);
String content = responseWrapper.toString();
System.out.println("Output : " + content); // here i found empty output on command line but output is returned to jsp page.
}
}
public class StringOutputStream extends OutputStream {
private StringWriter stringWriter;
public StringOutputStream(StringWriter stringWriter) {
this.stringWriter = stringWriter;
}
public void write(int c) {
stringWriter.write(c);
}
}
我更新的代码,但仍然没有运气有一些缺少的东西输出的Cuz在父母的反应仍在继续,当我调试代码getwritter不会被调用。 –