天天看点

ThreadLocal的使用[代码片段]

1、threadlocal定义,在一个类中定义:

在类a中:

其它方法:

//获取kcshtmlpath中的内容

kcshtmlpath.get();

//删除kcshtmlpath中的内容

kcshtmlpath.remove();

//设置参数

kcshtmlpath.set(value值);

设置参数的方式:

可以在类b中:

a.getkcshtmlpath().set(getrequest().getcontextpath() + "/");