- package cn.itcast.itcastweb.web.servlets;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- public class MyServlet extends HttpServlet {
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
- ClassLoader loader=this.getClass().getClassLoader();
- while(loader!=null){
- System.out.println(loader.getClass().getName());
- loader=loader.getParent();
- }
- out.close();
- }
- }
复制代码 ClassLoader loader=this.getClass().getClassLoader();中的this代表什么? |