由于本人欠考虑,导致使用session的工具类出现错误,在此将修正的代码重贴(在此表示歉意):
package com.fujitsu.eFrame.eftool; import javax.servlet.http.HttpSession; import com.fujitsu.uji.DispatchContext;import com.fujitsu.uji.http.HttpSessionProfile; public class SessionUtil { private static HttpSession getSession(DispatchContext context) { return ((HttpSessionProfile)context.getSessionProfile()).getSession();
} public static Object getAttribute(DispatchContext context, String name) { try { return getSession(context).getAttribute(name); } catch (IllegalStateException ex){ return null; } } public static void setAttribute(DispatchContext context, String name, Object value) { getSession(context).setAttribute(name, value); } public static void setTimeout(DispatchContext context, int seconds) { getSession(context).setMaxInactiveInterval(seconds); }}
博主因考虑不周,导致session工具类出错,现分享修正后的代码。代码包含获取session、获取属性、设置属性和设置超时时间等方法,涉及javax.servlet.http.HttpSession等相关类的使用。
2万+

被折叠的 条评论
为什么被折叠?



