; return java.util.UUID.randomUUID().toString() + '.' + this.getJvmRoute(); } return java.util.UUID.randomUUID().toString(); } public void start() throws LifecycleException { this.setPathname(""); // must disable session persistence across Tomcat restarts super.start(); this.initPool(); } public void stop() throws LifecycleException { super.stop(); this.closePool(); }}---------------------------------------------------------------------------------------------------package org.apache.catalina.session;import com.danga.MemCached.*;import org.apache.catalina.*;public class MemcachedSession extends StandardSession { protected transient MemCachedClient mc = null; public MemcachedSession(Manager manager, MemCachedClient mc) { super(manager); this.mc = mc; } public Object getAttribute(String name) { Object obj = super.getAttribute(name); if (obj != null && !(obj instanceof java.io.Serializable)) { return obj; } String key = name + this.getId(); obj = mc.get(key); return obj; } public void setAttribute(String name, Object value) { removeAttribute(name); super.setAttribute(name, value); if (value != null && value instanceof java.io.Serializable) { String key = name + this.getId(); mc.set(key, value); } } protected void removeAttributeInternal(String name, boolean notify) { super.removeAttributeInternal(name, notify); String key = name + this.getId(); mc.delete(key); } public void expire(boolean notify) { mc.delete(((MemcachedManager) manager).getSnaidPerfix() + this.getId()); super.expire(notify); } }(可以使用自己项目中memcache的操作类来替代上面两个类的memcache操作)将两个类打jar包,置于tomcat/lib下修改tomcat/conf/context.xml文件,内容如下:<?xml version='1.0' encoding='utf-8'?><Context> <Loader delegate="