|
|
Struts1 to Struts2 Migration
|
Struts1 and Struts2 can run side by side, within the same web
application. Developers can implement new features in the latest version,
and migrate older pieces as needed. Optionally, some common
resources may be shared between Struts1 and Struts2, like messages, validation
rules, and Tiles configurations, making for an even smoother
migration.
Here is what you can do to make it successful:
|
- Add the Struts 2.0 Jar files to your exisitng Struts1.x application.
- Configure Struts2 to handle .action requests and let Struts1 handle .do requests.
- Study known Struts1 applications, rewritten for Struts 2 -
Familiar applications such as the Struts Mailreader are being
rewritten to demonstrate best practices for Struts2.
- Use or create a tool that
reads the web.xml and Struts1 configuration files, and generates the
corresponding Struts2 configuration files. Comparing the
converted files with the originals could also serve as a training
tool.
-
Modify objects to utilize existing Struts1 resources, and utilities to
convert resources to Struts2 equivalents.
-
Create a Struts2 TextProvider that retrieves messages from the Struts1
MessageResources instance in the servlet context.
- Create an Interceptor that
can apply Struts1 validations to Struts2 actions, converting error messages
to Struts2 format. An Action and/or Interceptor that executes a Commons
Chain instance.
-
Implement Struts2 Action interface on Struts1 Action; Extend Session-Aware
Interceptor to set properties corresponding to Struts1 execute parameters
and populate. Extend the Struts1
Action Interceptor to load and process PlugIns
-
Utilize XSLT and other text processing tools to convert
Struts1 configuration file struts-config.xml to Struts2 configuraion file struts.xml, validations.xml to a global Struts2
validations.xml, and Struts1 message resources to global Struts2
resource.properties
-
Convert Struts1 Action classes to session-aware
Struts2 Action classes
- Convert Struts1 JSPs to Struts2 JSPs
|
|