是否可以通过ServletAPI将自定义ID分配给HTTP会话?
发布于 2018-08-02 10:01:10
如果使用Tomcat,可以创建自定义会话管理器,然后就可以访问Tomcat了
发布于 2018-08-02 10:42:27
如果你生成唯一ID的代码,可以这样做:
/**
* The String key of the user id attribute.
*/
public static final String USER_ID_KEY = "userIdKey";
// Set the user attribute (createUniqueUserId's parameters and return type are up to you)
httpSession.setAttribute(USER_ID_KEY, createUniqueUserId());
// Retrieve the user attribute later
httpSession.getAttribute(USER_ID_KEY);
https://stackoverflow.com/questions/-100000482
复制相似问题