public void init(ServletConfig cnf) throws ServletException {
        super.init(cnf);
        ServletContext cnt=cnf.getServletContext();
        ContextObject obj=new ContextObject();
        obj.startTimeStamp();
        cnt.setAttribute("obj",obj);
        System.out.println("ContextObjectServlet.init()");
    }init中的ServletConfig cnf是参数还是什么???参数能调用方法么???cnf.getServletContext();另外setAttribute()方法是什么意思???感谢老鸟!!!!!!

解决方案 »

  1.   

    init中的ServletConfig cnf  是参数.
    cnf.getServletContext();   可以的  对象作为参数的时候,可以调用它自己的方法.
    setAttribute()方法是什么意思???这个就查api吧
    给你个学习的方法:碰到java本身的类里面没有见过的方法,去查API文档.
      

  2.   

    cnf 是传递给这个方法的参数当然可以调用这个参数的方法setAttribute 就是把obj对象用名字obj存放在SevletConntext 访问内
      

  3.   

    1.是参数
    2.是对象就能调用方法
    3.cnf.getServletContext()--获得servlet上下文
    4.setAttribute()--在上下文中计入键和值
      

  4.   

    ServletConfig cnf是参数,也就是传进来了一个ServletConfig类的对象
    ,然后你当然就可以调用这个对象的任何可以调用的方法
      

  5.   

    init中的ServletConfig cnf是参数还是什么???参数能调用方法么???cnf.getServletContext(); cnf      a ServletConfig object containing the servlet's configuration and initialization parameters
    另外setAttribute()方法是什么意思???           Binds an object to a given attribute name in this servlet context。相信LZ可以看懂,SetAttribute("","");通俗点说就是给Obj取个别名,当然这样只是便于理解。(不是想误导你)
      

  6.   

    init中的ServletConfig cnf是参数,传进来其实就是对象,当然可以调用对象的方法