框架中的单例模式

来源:互联网 发布:淘宝跳转链接代码 编辑:程序博客网 时间:2024/05/22 18:34

Struts1

public class testAction extends Action{

       public ActionForword execute(ActionMapping mapping,ActionForm from,HttpservletRequest request,

HttpServletResponse response) throws Exception{

System.out.println(this);

return mapping.findForwart("success");

}

}

输出com.struts1.action.IndexAction@3c35fd 

Struts2

public class testAction extends Action{

       public ActionForword execute(ActionMapping mapping,ActionForm from,HttpservletRequest request,

HttpServletResponse response) throws Exception{

System.out.println(this);

return mapping.findForwart("success");

}

}

 com.struts2.action.IndexAction@1f327e  

HttpServlet

public class testServlet extends HttpServlet{

protected void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{

doPost(req,res);

}

protected void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{

System.out.println(this);

}


}









0 0