swfupload上传 firefox flash session问题【备忘】

1、后台保存session。

public class MySessionContext {
	private static HashMap mymap = new HashMap();

	public static synchronized void AddSession(HttpSession session) {
		if (session != null) {
			mymap.put(session.getId(), session);
		}
	}

	public static synchronized void DelSession(HttpSession session) {
		if (session != null) {
			mymap.remove(session.getId());
		}
	}

	public static synchronized HttpSession getSession(String session_id) {
		if (session_id == null)
			return null;
		return (HttpSession) mymap.get(session_id);
	}
}
public class MySessionListener implements HttpSessionListener {
	public void sessionCreated(HttpSessionEvent httpSessionEvent) {
		MySessionContext.AddSession(httpSessionEvent.getSession());
	}

	public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
		HttpSession session = httpSessionEvent.getSession();
		MySessionContext.DelSession(session);
	}
}
<listener>
 <listener-class>com.smarter.filter.MySessionListener</listener-class>
</listener>

2、request url 中带上sessionid参数

upload_url : rootPath+"uploadFileAc!upSwf.s", //接收上传的服务端url
	     flash_url : rootPath+"d/scripts/swfupload/Flash/swfupload.swf",//swfupload压缩包解压后swfupload.swf的url
	     button_placeholder_id : "swfu-placeholder1",//上传按钮占位符的id
	     file_types : "*.jpg;*.gif;*.png",
	     file_post_name : "uploadForm.file",
	     post_params:{
	    	 "uploadForm.type":"2",
	         "jsessionid":sessionId
	     },
	     use_query_string : true,

3、后台通过id获取session进行处理。

if(request.getParameter("jsessionid") != null){
			session = MySessionContext.getSession(request.getParameter("jsessionid"));
		}

转载于:https://my.oschina.net/u/151615/blog/158626

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值