]]>WebWork涓殑妯″瀷椹卞姩闂娉ㄦ剰http://www.aygfsteel.com/TiGERTiAN/archive/2007/04/11/109973.htmlTiGERTiANTiGERTiANWed, 11 Apr 2007 10:30:00 GMThttp://www.aygfsteel.com/TiGERTiAN/archive/2007/04/11/109973.htmlhttp://www.aygfsteel.com/TiGERTiAN/comments/109973.htmlhttp://www.aygfsteel.com/TiGERTiAN/archive/2007/04/11/109973.html#Feedback0http://www.aygfsteel.com/TiGERTiAN/comments/commentRss/109973.htmlhttp://www.aygfsteel.com/TiGERTiAN/services/trackbacks/109973.html//Example 1: This is wrong: publicclass ViewHeadlineAction implements Action, ModelDriven { Headline headline =new Headline(); public Object getModel() { returnthis.headline ; } // public String execute() { headline = headlineFactory.findLatest(); return SUCCESS; } } b//Example 2: This is correct: publicclass ViewHeadlineAction implements Action, ModelDriven { Headline headline =new Headline(); public Object getModel() { returnthis.headline ; } // public String execute() { headlineFactory.updateToLatest(headline); return SUCCESS; } } Example 1 attempts to change the instance that getModel() returns. However, because getModel() is called before execute() and before the object is pushed onto the value stack, the reference that WebWork uses is the original instance, created by new Headline(), not the instance loaded from the HeadlineFactory. The second example resolves this issue by updating the existing instance rather than having headline point to a new instance.