81,092
社区成员
发帖
与我相关
我的任务
分享
try {
form = alipayClient.pageExecute(alipayRequest).getBody(); //调用SDK生成表单
} catch (AlipayApiException e) {
e.printStackTrace();
}
httpResponse.setContentType("text/html;charset=" + CHARSET);
httpResponse.getWriter().write(form);//直接将完整的表单html输出到页面
httpResponse.getWriter().flush();
httpResponse.getWriter().close();
}
// 调用SDK生成表单
form = client.pageExecute(alipay_request).getBody();
response.setContentType("text/html;charset=" + AlipayConfig.input_charset);
response.getWriter().write(form);//直接将完整的表单html输出到页面
response.getWriter().flush();
response.getWriter().close();
但是呢, 现在界面是VUE写的, 发现直接 response.getWriter().write(form); 没有反应.. (含有自动跳转js)
现在的解决方法是 把form截取<script>前内容,然后前端创建html 再次提交.. 没有response直接 write干脆.
那直接write html(包含form,自动提交,还有alipay的js)呢,,这边还是不行, 因为 html直接打印时,发现 和外层的html开头冲突了, 标签变成了内容(灰色字符). resp.setHeader("Content-Type", "text/html;charset=utf-8");
PrintWriter out = resp.getWriter();
System.out.println(client.buildPostForm(request));
out.write("<html>");
out.write("<head>");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
out.write("</head>");
out.write("<body>");
out.write(form);
out.write("</body>");
out.write("</html>");
以前这样写过,可以的。