注意:该操作是在servlet2.2以后得版本不支持原有的getSessionid |
step1:添加session 监听器配置web.xml |
<listener>
<listener-class>
com.keweisoft.ecmp.httpsessionlistener.ScsSeesionListener
</listener-class>
</listener>
package com.keweisoft.ecmp.httpsessionlistener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
public class ScsSeesionListener implements
HttpSessionListener{
private PayNotifySessionContext sessionContext=
PayNotifySessionContext.getInstance();
public void sessionCreated(HttpSessionEvent event) {
HttpSession session=event.getSession();
sessionContext.addSession(session);
}
public void sessionDestroyed(HttpSessionEvent envent) {
HttpSession session=envent.getSession();
sessionContext.removeSession(session);
}
}
package com.keweisoft.ecmp.httpsessionlistener;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession;
public class PayNotifySessionContext {
private static PayNotifySessionContext sessionContext=new PayNotifySessionContext();
private Map<String,HttpSession> sessionMap=new HashMap<String, HttpSession>();
private PayNotifySessionContext()
{
}
public static PayNotifySessionContext getInstance()
{
return sessionContext;
}
public synchronized void addSession(HttpSession session)
{
if(null!=session)
{
sessionMap.put(session.getId(), session);
}
}
public synchronized void removeSession(HttpSession session)
{
if(null!=session)
{
sessionMap.remove(session.getId());
}
}
public synchronized HttpSession getSession(String JSESSIONID)
{
HttpSession session =JSESSIONID==null?null:sessionMap.get(JSESSIONID);
return session;
}
}
step4通过支付通知路径保存当前的JSESSIONID |
//本例为支付宝 支付通知URL携带以下可能因支付而丢失的保存在SESSION中的值
alipay.setReturn_url(SysConfigLoader.getSystemConfig().getProperty(
"returnUrl")
+ "?JSESSIONID="
+ JSESSIONID
+ "&areaId="
+ areaId
+ "&payAreaId=" + payAreaId);
//支付成功之后那么该URL就会跨域请求你的服务器并携带了这些值你索要做的就是找到你的
session后替换到生成的新的session
this.getRequest().getSession().setAttribute(
".freemarker.Session",
null == session.getAttribute(".freemarker.Session") ? session
.getAttribute(".freemarker.Session") : null);
this.getRequest().getSession().setAttribute("user", session.getAttribute("user"));
this.getRequest().getSession().setAttribute("randomKey",
session.getAttribute("randomKey"));
this.getRequest().getSession().setAttribute(
"javax.servlet.jsp.jstl.fmt.request.charset",
session.getAttribute("javax.servlet.jsp.jstl.fmt.request.charset"));
分享到:
相关推荐
jsp支付宝对接案例 网上银行对接案例,例子有gbk跟uft两种编码格式的例子,希望能帮助到大家
临商银行接口对接,加密解密加签验签整合,方便调用 临商银行接口对接,加密解密加签验签整合,方便调用 临商银行接口对接,加密解密加签验签整合,方便调用 临商银行接口对接,加密解密加签验签整合,方便调用 临商...
大额支付系统直连商业银行对接测试流程.doc
通过第三方支付公司与银行对接: 这种方式接方式的优缺点: 优点:系统只需要与第三方支付公司打交道,第三方支付公司根据用户选择的支付银行,并根据支付银行的接入规范,引导用户与银行对接,从而实现支付。此种...
民生银行接口对接201809011
本手册是根据中国银行网上银行银企对接前置机系统1.1编写的应用系统安装手册 。 由于编者水平有限,错误和疏漏在所难免,敬请读者谅解。随着银企对接系统的更新和发展,本手册的内容将不断修改和完善。 一、...
招行银企直连对接java开发demo示例,可以参照代码进行银企直连的开发
java招商银行接口文档,源码java招商银行接口文档,源码java招商银行接口文档,源码java招商银行接口文档,源码
工行e生活对接文档的包含一些介绍e生活的介绍文档和UI的规则,还有一些接口文档同时包含App,以及测试版终端的下载方法,和一些测试信息的内容
这段代码实现了系统与支付宝的对接。实现了电子商务系统实现支付的功能,并接受了对接的借口和协议
民生银行接口对接201810181
易宝对接案例,网上银行对接案例 包括三种开发语言案例都有 jsp php asp的,希望对大家有用
01 H3C S5500与思科3750对接二层链路聚合的典型组网配置案例 02 H3C S5500与思科2960对接二层链路聚合的典型组网配置案例 03 H3C S6800与思科3560对接二层链路聚合典型组网配置案例 04 H3C S6800与思科2960对接二...
对接金蝶的demo,帮助快速对接金蝶webapi,金蝶,java,webapi帮助工具
卡盟货源对接软件
银行外网系统对接核心接口参考文档scoket
浦发银行支付api对接,使用java语言实现,包括签名,sm2方式的加解密。使用okhttp框架调用浦发银行api。适用于支付、退款以及查询支付或退款结果的接口。它还依赖于其他的几个基础jar,详细见于本jar包里的Pom.xml...
中国银行银企服务器负载均衡部分采用Radware公司的WSD产品,Radware的WSD其硬件架构,专用的网络操作系统确保了系统的可靠性,系统的性能以及系统的安全性。Radware为银企系统部署2台WSD,2台WSD可以做到互为备份,...