我试图通过遵循this example创建IPN侦听器:

public class IPNListenerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ConfigManager.getInstance().load(this.getClass().getResourceAsStream("/sdk_config.properties"));
        IPNMessage  ipnlistener = new IPNMessage(request);
        boolean isIpnVerified = ipnlistener.validate();
        String transactionType = ipnlistener.getTransactionType();
        Map<String,String> map = ipnlistener.getIpnMap();

        LoggingManager.info(IPNListenerServlet.class, "******* IPN (name:value) pair : "+ map + "  " +
                "######### TransactionType : "+transactionType+"  ======== IPN verified : "+ isIpnVerified);
    }
}


但是不建议使用ConfigManager.getInstance().load(),并且在我的项目中,配置文件不在默认位置,因此,加载配置文件的正确方法是什么?

最佳答案

可能的解决方案:


在默认位置提供一个空的sdk_config.properties;
手动加载属性文件,获取相关的映射并将其传递给IPNMessage构造函数;


更多信息here

10-04 21:52