如题:Methodmethod=getClass().getDeclaredMethod,getClass()前面省略的“this.”是指的CustomerServlet吗?JSP页面源码:Query Delete 以下是CustomerServlet源码:@WebServlet(name="CustomerServlet",urlPatterns={"*.do"})publicclassCustomerServletextendsHttpServlet{privatestaticfinallongserialVersionUID=1L;protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{doPost(request,response);}protectedvoiddoPost(HttpServletRequestreq,HttpServletResponseresp)throwsServletException,IOException{StringservletPath=req.getServletPath();StringmethodName=servletPath.substring(1,servletPath.length()-3);System.out.println(methodName);try{Methodmethod=getClass().getDeclaredMethod(methodName,HttpServletRequest.class,HttpServletResponse.class);method.invoke(this,req,resp);}catch(Exceptione){}}privatevoiddelete(HttpServletRequestrequest,HttpServletResponseresponse){System.out.println("delete");}privatevoidquery(HttpServletRequestrequest,HttpServletResponseresponse){System.out.println("query");}}
胡子哥哥
梦里花落0921
相关分类