天天看點

ThreadLocal的使用[代碼片段]

1、threadlocal定義,在一個類中定義:

在類a中:

其它方法:

//擷取kcshtmlpath中的内容

kcshtmlpath.get();

//删除kcshtmlpath中的内容

kcshtmlpath.remove();

//設定參數

kcshtmlpath.set(value值);

設定參數的方式:

可以在類b中:

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