Struts1

Struts 1 (or just 'Struts') has been superseded by Struts 2 in recent years. There is still a huge community for Struts 1 web applications though.

To configure PicoContainer to handle the dependency injection of Struts actions, refer to the web.xml below.

web.xml

	
	
	  PicoContainer-Web and Struts1 Webapp

	  
	    webapp-composer-class
	    *your web app composer class name*
	  

	  
	    picoFilter
	    org.picocontainer.web.struts.PicoActionFactory$ServletFilter
	  

	  
	    picoFilter
	    *.do
	  

	  
	    org.picocontainer.web.PicoServletContainerListener
	  

	  
	  
	    action
	    org.apache.struts.action.ActionServlet
	    
	      config
	      /WEB-INF/struts-config.xml
	    
	    2
	  

	  
	  
	    action
	    *.do
	  

	  
	  
	    index.html
	  

	

	

struts-config.xml

Things are different in the struts-config.xml file though - there is a PicoContainer enabled RequestProcessor:

	  
	    
	    
	  

	  
	    
	      
	    
	  

	  
		
	

With this design you can use Constructor Injection and three tier container scoping for Struts web applications. Make sure you make and configure your own WebappComposer implementation.

See downloads on how to download the struts module either using Maven or by downloading full distribution.

Example App

We have a sample application. It is a small form-style web-app that shows and list of cheeses, allows you to add and delete from the list. See the Maven2 source for it. Here is a screenshot of it running:

Download the war file for it (full Java source in WEB-INF/classes).