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

14 篇文章 1 订阅
5 篇文章 1 订阅

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 -

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值