struts2.0 升级到 struts2.1.2 更改的配置项(一)

来源:互联网 发布:淘宝搬家到另一个店铺 编辑:程序博客网 时间:2024/05/15 00:51

struts2.0 升级到 struts2.1.2 更改的配置项(一)(2008-11-06 18:12:15)标签:struts2.1.2 struts2.0 ajaxtags   

Troubleshooting guide migrating from Struts 2.0.x to 2.1.x

About the Migration guide

This guide describes how to migrate an existing Struts 2.0.x application to Struts 2.1.x. It is intended to be read from top to bottom but you may skip-ahead to known problems and common exceptions. Please edit this page or provide comments if you encounter additional issues.

 

Update Dependencies
Update your project dependences to use struts2-core-2.1.x and the plugins struts2-core-2.1.x.

 There have been significant changes to the Configuration API between 2.0 and 2.1. Third-party plugins for 2.0 may not be compatible with 2.1.x.

Maven users can update their project's pom.xml to reference the new core and plugin versions. Ensure no dependencies in the freemarker groupId are used as the latest version used by Struts is now under the org.freeemarker groupId and will cause classpath conflicts.

If you need releases not considered General Availability you can use a staging repository where they are usually available:

<repositories> <repository> <id>struts2.1.2-staging</id> <name>Struts 2.1.2 staging repository</name> <layout>default</layout> <url>http://people.apache.org/builds/struts/2.1.2/m2-staging-repository/</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
Non-Maven users can can download the jars and dependencies in a Distribution 2.1.2

 DELETE OLD VERSIONS NOW: It's essential that old versions of the jars are removed from your project as well as the deployment directories. Don't trust your IDE to delete unused versions.
eg. Your application is now be dependent on xwork-2.1.x, not xwork-2.0.x. Ensure xwork-2.0.x is completely removed or you will encounter compile-time and run-time exceptions.

Update Custom Type Converters
If your project implements custom type converters you may need to change the imports statements to use the com.opensymphony.xwork2.conversion package. Failing to do so will cause a compile-time error.

Before:

import com.opensymphony.xwork2.util.TypeConversionException;
After:

import com.opensymphony.xwork2.conversion.TypeConversionException;
Update struts.xml Configuration
Results and Interceptors have been renamed to use camelCase instead of hyphenated names (eg. now redirectAction instead of redirect-action).
Review all custom interceptor stacks, interceptor refs and results in struts.xml and remove the hyphen.

Interceptors:

From        To
external-ref externalRef
model-driven modelDriven
static-params staticParams
scoped-model-driven scopedModelDriven
servlet-config servletConfig
token-session tokenSession

Results:

From           To
redirect-action redirectAction
plaintext plainText
 Forgetting to rename an interceptor or result reference will prevent your WebApp from starting. The following is a typical stacktrace for an invalid result type.
SEVERE: Exception starting filter struts2 Unable to load configuration. - action - file:/home/giaz/code/.metadata/.plugins/ com.genuitec.eclipse.easie.tomcat.myeclipse/tomcat/webapps/webui/WEB-INF/classes/struts.xml:39:98 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:370) ... Caused by: Error building results for action ScheduleJob in namespace - action - file:/home/giaz/code/.metadata/.plugins/
                                                                                    .addAction(XmlConfigurationProvider.java:372) ... 30 more Caused by: There is no result type defined for type 'redirect-action' mapped with name 'success' - result -

原创粉丝点击