⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sessionprocess.java

📁 随书光盘:精通Sping 2.0 的随书源代码
💻 JAVA
字号:
package test;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * ISessionContent实现
 * 
 * @author worldheart
 * 
 */
public class SessionProcess implements ISessionProcess {

	public void processSessionContent(HttpSession hs) {
		if (hs == null)
			return;
		ServletContext sc = hs.getServletContext();
		ApplicationContext ac = WebApplicationContextUtils
				.getRequiredWebApplicationContext(sc);

		ISessionContent sessionContent = (ISessionContent) ac
				.getBean("sessionContent");

		Enumeration enumer = hs.getAttributeNames();

		Map<String, String> map = new HashMap<String, String>();

		while (enumer.hasMoreElements()) {
			String name = (String) enumer.nextElement();
			if(name.indexOf("scopedTarget.nameList") == -1 && name.indexOf("scopedTarget.valueList") == -1
					&& name.indexOf("sessionProcess") == -1)
				map.put(name, (String) hs.getAttribute(name));
		}

		sessionContent.processSessionContent(map);

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -