激活开发者模式的时候我用了第三方的网关,现在想改成自己的,需要改成自己的网关: www.betafenqi.com/gateway_alipay.aspx
确定修改的时候有个错误提示:应用网关响应异常。
支付宝上面的demo让我稍作修改,集成到我的ssh工程中了,因为是线上测试,所以不容易找出什么问题,知道的大神帮下忙呗。下面是我的代码(没贴出调用部分,和demo基本一致):
public String alipay() throws MyException{
System.out.println("网关--支付宝test~");
System.out.println("接受参数。。");
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
Map<String,String> pars = RequestUtil.getRequestParams(request);
System.out.println("参数。。"+pars.toString());
if(!("{}".equals(pars.toString()))){
url = "index.jsp";
String service = pars.get("service");
String bizContent = pars.get("biz_content");
JSONObject bizContentJson = (JSONObject) new XMLSerializer().read(bizContent);
System.out.println("bizContent:"+bizContent);
Event event = gatewayServ.getEvent(service, bizContentJson);
String responseMsg = event.execute();
try {
responseMsg = AlipaySignature.encryptAndSign(responseMsg,
AlipayConfig.ALIPAY_PUBLIC_KEY,
AlipayConfig.PRIVATE_KEY, AlipayConfig.CHARSET,
false, true);
} catch (AlipayApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
//http 内容应答
response.reset();
response.setContentType("text/xml;charset=GBK");
PrintWriter printWriter;
printWriter = response.getWriter();
printWriter.print(responseMsg);
response.flushBuffer();
System.out.println("response串:"+response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//根据业务参数获取
}else{
System.out.println("参数为空");
url = "test.jsp";
}
returnSUCCESS;
}
代码执行没问题