博客已移至 http://blog.gogl.top
shiro有自己的sesison概念,shiro的session并不是java ee的session。通常,我们看到shiro的sessionId格式类似c6395bbc-425d-43b3-a444-04fee5a92e95,是因为shiro产生sesisonId是通过UUID生成的。我们可以看到shiro-core-xx.jar的org.apache.shiro.session.mgt.eis包下有个JavaUuidSessionIdGenerator,shiro的sessionId默认是通过该类生成的。可以看看源码。
public class JavaUuidSessionIdGenerator implements SessionIdGenerator {
/**
* Ignores the method argument and simply returns
* {@code UUID}.{@link java.util.UUID#randomUUID() randomUUID()}.{@code toString()}.
*
* @param session the {@link Session} instance to which the ID will be applied.
* @return the String value of the JDK's next {@link UUID#randomUUID() randomUUID()}.
*/
public Serializable generateId(Session session) {
return UUID.randomUUID().toString();
}
}
是通过调用java的UUID来生成一个唯一的I