yaray(雅睿,生活在别处)兄弟,我试过了,这样不行的。
有个老外对这个问题做出了回答如下
getRequestDispatcher() returns null inside new thread
Question by Geetha Menon on Tue, 02 Oct 2001 08:05:18 -0700 (PDT)
Within the run method of a thread, getRequestDispatcher() returns null. Why is this so? Is there a way to overcome this?
Answer by Scott Ferguson on Fri, 16 Nov 2001 12:57:44 -0800 (PST)
Separate threads need to be very careful when using the servlet API. For example, you can't use the Request or Response objects in a separate thread.
You can use the ServletContext in a separate thread, but you need to make sure that the servlet that creates the thread in the init() method closes it in the destroy() method. Otherwise, your thread will point to an obsolete and closed ServletContext when the web.xml or any classes change.