您的位置:首页 > 其它

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

2013-09-02 00:00 183 查看
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"));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐