`
收藏列表
标题 标签 来源
tomcat session Tomcat的Session管理(一) - Session的生成
	protected void doLoad() throws ClassNotFoundException, IOException {
		if (log.isDebugEnabled())
			log.debug("Start: Loading persisted sessions");

		// 清空Map
		sessions.clear();

		// 对应work/Catalina/localhost/%app name%/SESSIONS.ser文件
		File file = file();
		if (file == null)
			return;
		if (log.isDebugEnabled())
			log.debug(sm.getString("standardManager.loading", pathname));
		FileInputStream fis = null;
		ObjectInputStream ois = null;
		Loader loader = null;
		ClassLoader classLoader = null;
		try {
			// 载入Session缓存文件
			fis = new FileInputStream(file.getAbsolutePath());
			BufferedInputStream bis = new BufferedInputStream(fis);
			if (container != null)
				loader = container.getLoader();
			if (loader != null)
				classLoader = loader.getClassLoader();
			if (classLoader != null) {
				if (log.isDebugEnabled())
					log.debug("Creating custom object input stream for class loader ");
				ois = new CustomObjectInputStream(bis, classLoader);
			} else {
				if (log.isDebugEnabled())
					log.debug("Creating standard object input stream");
				ois = new ObjectInputStream(bis);
			}
		} catch (FileNotFoundException e) {
			if (log.isDebugEnabled())
				log.debug("No persisted data file found");
			return;
		} catch (IOException e) {
			log.error(sm.getString("standardManager.loading.ioe", e), e);
			if (ois != null) {
				try {
					ois.close();
				} catch (IOException f) {
					;
				}
				ois = null;
			}
			throw e;
		}

		synchronized (sessions) {
			try {
				// 读出Session个数
				Integer count = (Integer) ois.readObject();
				int n = count.intValue();
				if (log.isDebugEnabled())
					log.debug("Loading " + n + " persisted sessions");
				//  读入Session
				for (int i = 0; i < n; i++) {
					StandardSession session = getNewSession();
					session.readObjectData(ois);
					session.setManager(this);
					sessions.put(session.getIdInternal(), session);
					session.activate();
					sessionCounter++;
				}
			} catch (ClassNotFoundException e) {
				log.error(sm.getString("standardManager.loading.cnfe", e), e);
				if (ois != null) {
					try {
						ois.close();
					} catch (IOException f) {
						;
					}
					ois = null;
				}
				throw e;
			} catch (IOException e) {
				log.error(sm.getString("standardManager.loading.ioe", e), e);
				if (ois != null) {
					try {
						ois.close();
					} catch (IOException f) {
						;
					}
					ois = null;
				}
				throw e;
			} finally {
				try {
					if (ois != null)
						ois.close();
				} catch (IOException f) {
				}

				// 删除Session缓存文件
				if (file != null && file.exists())
					file.delete();
			}
		}

		if (log.isDebugEnabled())
			log.debug("Finish: Loading persisted sessions");
	}
jquery动态添加option
$(document).ready(function() {
	//为获取List对象按钮添加鼠标单击事件
		var departId = $("#departId").val();
		$.getJSON("book!getOperatorList.action?name=" + departId,
				function(data) {
					//清空显示层中的数据
				$("#message").html("");
				//使用jQuery中的each(data,function(){});函数
				//从data.userInfosList获取UserInfo对象放入value之中
				$.each(data.list, function(i, value) {
					$(
							"<option value='" + value.opId + "'>"
									+ value.opName + "</option>").appendTo(
							"#selectId");
				});
			});

	});
Global site tag (gtag.js) - Google Analytics