Provides integration between Grails and the Struts 1 framework
Dependency :
compile ":struts1:1.3.11"
Summary
A plug-in that makes Struts 1 (http://struts.apache.org/) the default controllfer/view rendering framework for Grails. Struts
is an older first generation framework and this plug-in facilitates migration away from Struts to a modern stack like Grails.
If you want to use this with Grails 1.3.x, you must use v1.3.10 of this plugin as Grails 2 introduced breaking changes.
Description
Struts 1 Plug-in for Grails
Grails is a full stack framework that provides everything from the build system to the persistence layer. Struts 1 is a first generation Java web framework that is still very popular, but it only solves the controller/view layer.current plugin source is at: https://github.com/rvanderwerf/grails-struts1This plug-in allows you to use Struts 1 as a the controller/view layer for Grails and also provides a migration path to Grails from Struts 1.For Grails 1.0 you will need version 1.3.8.1 of the plugin, whilst for Grails 1.1 and above you will need version 1.3.8.2 or above of the plugin
Getting Started
Once you have created a Grails application, you need to install the plug-in. The plug-in is hosted in the Grails central repository and can be installed with:grails install-plugin struts1
grails install-plugin /path/to/file/grails-struts1-1.3.8.zip
grails.mime.file.extensions = falsegrails run-app
Migrating an Existing Struts application
To migrate an existing Struts 1 application you can simply:- Copy your struts-config.xml and validation.xml into web-app/WEB-INF over writing the existing ones if necessary
- Copy Java sources into src/java
- Copy all dependant JAR files into the lib directory
Forwarding to a GSP view from Struts
You'll notice that by default the struts-config.xml setup by Grails has the following mapping:<action
path="/Welcome"
forward="/index.gsp"/>Mapping a Struts action to a Grails controller
If you prefer to write your controller logic in Grails controller you can do so and use the ControllerActionProxy class to map to it. For example given the following Grails controller:class TestController {
def foo = {
println "EXECUTING FOO"
}
}<action
path="/test/foo"
type="org.codehaus.grails.struts.action.ControllerActionProxy"
/>- actionMapping - An instance of the Struts ActionMapping class
- actionForm - An instance of the Struts ActionForm class if one is configured for the Action
Tips
- Be sure to pick Plugin 1.3.8.1, not 1.3.8
- rvanderwerf
- If your struts code uses file uploads, see jira http://jira.grails.org/browse/GPSTRUTS1-1 for the code to override multipartResolver bean with one that is struts aware.