By tigerhere on Jan 02, 2008
One of the students, 周羽 (2 from the right in class photo below), modified my struts examples to use spring. I am now analyzing his NetBeans projects for use in future teachings. His notes are below, I have added his samples to the Framework download zip file.
During lunch, a few of us went for Japanese food which was good. After the class, Lily (right most in class photo below) and I went for excellent wong tong at a tourist area. It was fun eating, shopping, and walking around. The difficult part was finding taxis because it was lightly raining and we were in busy areas which meant competition for taxis.
The First Way.
The addGameAction must be extended ActionSupport(ActionSupport is a class from Spring). And use ApplicationContext.getBean() to get LeagueService. I don't like this way because it's too close-coupled.
The Second Way.
The addGameAction still extend Action(Class of Struts).But add 1 attribute in addGameAction.The attribute is LeagueService. Change the default RequestProcessor to org.springframework.web.struts.DelegatingRequestProcessor. Then can Dependency Injection via Spring. This way is better than first way.But it isn't the best way because it's changed default RequestProcessor in Struts.
The Third Way.
Still Inject the LeagueService via Spring.But it's no need to change the default RequestProcessor. It's AOP.Use the Spring interceptor to intercept Action class. In struts-config.xml,change the "