Authored by qinchao

加下日志

... ... @@ -134,5 +134,11 @@
<artifactId>alipay-sdk-java</artifactId>
<version>3.4.27.ALL</version>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
... ...
... ... @@ -4,29 +4,25 @@
*/
package com.alipay.servlet.gateway;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConstants;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradeAppPayModel;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.internal.util.StringUtils;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.constants.AlipayServiceEnvConstants;
import com.alipay.dispatcher.Dispatcher;
import com.alipay.executor.ActionExecutor;
import com.alipay.factory.AlipayAPIClientFactory;
import com.alipay.util.LogUtil;
import com.alipay.util.RequestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
/**
* 开发者网关,支付宝所有主动和开发者的交互会经过此网关进入开发者系统(配置在开放平台的应用网关)
... ... @@ -36,6 +32,9 @@ import com.alipay.util.RequestUtil;
*/
public class GatewayServlet extends HttpServlet {
private final static Logger logger = LoggerFactory.getLogger(GatewayServlet.class);
/**
*
*/
... ... @@ -46,8 +45,10 @@ public class GatewayServlet extends HttpServlet {
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
IOException {
logger.info("enter ali GatewayServlet req {} ",req);
this.doPost(req, resp);
logger.info("enter ali GatewayServlet end ");
}
/**
... ... @@ -59,6 +60,7 @@ public class GatewayServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,
IOException {
logger.info("enter ali GatewayServlet post ");
//支付宝响应消息
String responseMsg = "";
... ... @@ -82,11 +84,13 @@ public class GatewayServlet extends HttpServlet {
catch (AlipayApiException alipayApiException) {
//开发者可以根据异常自行进行处理
alipayApiException.printStackTrace();
logger.error("enter ali GatewayServlet post error {} ",alipayApiException);
}
catch (Exception exception) {
//开发者可以根据异常自行进行处理
exception.printStackTrace();
logger.error("enter ali GatewayServlet post exception {} ",exception);
} finally {
//5. 响应结果加签及返回
... ... @@ -110,6 +114,7 @@ public class GatewayServlet extends HttpServlet {
} catch (AlipayApiException alipayApiException) {
//开发者可以根据异常自行进行处理
alipayApiException.printStackTrace();
logger.error("enter ali GatewayServlet post exception {} ",alipayApiException);
}
}
}
... ... @@ -117,7 +122,7 @@ public class GatewayServlet extends HttpServlet {
/**
* 验签
*
* @param request‘
* @param
* @return
*/
private void verifySign(Map<String, String> params) throws AlipayApiException {
... ...
... ... @@ -5,6 +5,10 @@
package com.alipay.util;
import com.alipay.servlet.gateway.GatewayServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 日志打印工具
*
... ... @@ -13,13 +17,16 @@ package com.alipay.util;
*/
public class LogUtil {
private final static Logger logger = LoggerFactory.getLogger(GatewayServlet.class);
/**
* 信息日志打印
*
* @param prefixName 前缀名称
* @param params 参数
*/
public static void log(String prefixName, String msgContent) {
System.out.println(prefixName + " : " + msgContent);
logger.info("LogUtil "+prefixName + " : " + msgContent);
}
}
... ...