`
liumin1939
  • 浏览: 57381 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

StrutsUpgradeNotes11to124

阅读更多
Upgrading Struts 1.1 to Struts 1.2.x
jars
I guess its obvious to say you need to replace the jars, but the one people might forget is the new commons-validator.jar for version 1.1.3 of validator.

Also if you want to start using the new validwhen validation rule, then you will need to deploy the antlr.jar as well.

NOTE If your existing app uses the Struts SSLExt library, you must upgrade it as well:  http://sslext.sourceforge.net/

tlds
Remember to deploy the new versions of the tld files for struts tags. If you don't you won't be able to use the new tag attributes added.

NOTE The uri's in the struts tlds have changed from jakarta.apache.org/struts to struts.apache.org - however this shouldn't have any impact (see below)

Tag libraries can be configured in one of two ways:

A. If you have configured the tag libraries using entries in the web.xml (see  User Guide) then these should continue to work.

B. If you have used the simplified deployment allowed by Servlet 2.3 onwards (see  User Guide) then this should also continue to work as versions of the tld's with the old uri have now been included in the struts.jar (and struts-el.jar). Its recommended that for new development that you use the new uri

Struts 1.1  <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> 

Struts 1.2.x  <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 

validator.xml
Change the dtd declaration at the top to refer to the dtd for validator 1.1.3

<!DOCTYPE form-validation PUBLIC

"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN" " http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

validator-rules.xml
Upgrade to the new version of validator-rules.xml.

N.B. One of the changes in the new validator-rules.xml is that the Validation methods' signatures changed from using ActionErrors to ActionMessages. If you have any custom validation methods, remember to change their method signatures to now use ActionMessages.

struts-config.xml
Its not absolutely necessary but you should upgrade to the 1.2 version of the dtd (Note that as well as the version number changing so has the url to struts.apache.org).

<!DOCTYPE struts-config PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" " http://struts.apache.org/dtds/struts-config_1_2.dtd">

If you do upgrade to the 1.2 version dtd then there are a couple of attributes which have been removed and you will need to remove them from your struts-config:

debug has been removed from the "controller" element.

dynamic has been removed from the "form-bean" element

Also the contextRelative attribute in the "forward" element is now considered "deprecated" and a new module attribute added.

ActionError(s) and ActionMessage(s)
There is some confusion over ActionError and ActionErrors and whats deprecated.

A. ActionError IS deprecated and should be replaced by ActionMessage.

B. ActionErrors IS NOT deprecated. The Struts committers would have liked to have deprecated ActionErrors but because too much of core API depend on it (such as the ActionForm's validate method) it hasn't been. However it may be in the future and, where possible, you should now use ActionMessages in place of ActionErrors.

Theres more on this topic on StrutsDeprecatedActionErrors.

Custom Tags and Validation
Many methods in org.apache.struts.util.RequestUtils and org.apache.struts.util.ResponseUtils are deprecated. Replace RequestUtils.* and ResponseUtils.* with org.apache.struts.taglib.TagUtils.getInstance().*

Replace org.apache.commons.validator.ValidatorUtil with org.apache.commons.validator.util.ValidatorUtils.

<init-param> web.xml configuration
A number of the of init parameter entries (i.e. <init-param>) in the web.xml were marked as deprecated in the Struts 1.1 release and have been removed in Struts 1.2. A list of the init parameters which have been removed is given below (refer to the  User Guide for more information on Struts configuration):

mapping - see note on configFactory below

debug - replaced by  Commons Logging

bufferSize - moved to <controller> element in the struts-config.xml

content - renamed to contentType and moved to <controller> element in the struts-config.xml

locale - moved to <controller> element in the struts-config.xml

maxFileSize - moved to <controller> element in the struts-config.xml

nocache - moved to <controller> element in the struts-config.xml

multipartClass - moved to <controller> element in the struts-config.xml

tempDir - moved to <controller> element in the struts-config.xml

application - now parameter in the <message-resources> element in the struts-config.xml

factory - moved to <message-resources> element in the struts-config.xml

null - moved to <message-resources> element in the struts-config.xml

N.B. There is a new configFactory init parameter in Struts 1.2 which can be used to set a custom ModuleConfigFactory class. This could be used to initialize default ModuleConfig settings on a struts-wide basis.

<html:form> Tag Attribute Deprecations
The name, scope and type attributes on the <html:form> tag were deprecated in Struts 1.1 and have now been removed in Struts 1.2.

The <html:form> tag was enhanced in Struts 1.1 to automatically create a new ActionForm instance based on the action mapping from the struts-config.xml. However the behaviour associated with the name, scope and type attributes still functioned.

In struts 1.2 you need to remove these attributes from the <html:form> tag in your jsp. If the values for these attributes match what you have in the struts-config.xml for the mapping then just removing them should be the the only action you need to take.

If they are not the same then problems will almost certainly occur when you upgrade to Struts 1.2 and remove the attributes. If, for example, you have pre-filled a form and stored it in a different scope these will no longer be displayed and the form values appear to have been lost. This can be resolved either by changing the scope on the mapping or by storing the form in the correct scope.

MessageResource Bundle Requirement
When the TagUtils class was introduced, it inadvertently added a new minimum requirement for taglib-only uses of Struts (those not using the ActionServlet + struts-config.xml, but only the tag libraries). In several of the Struts tags, the method TagUtils.retrieveMessageResources() is called, which looks for the MessageResource bundle typically configured by the ActionServlet (and placed in application scope). In the case that it cannot be found in any scope, the method attempts to access the moduleConfig object, which for taglib-only users, is null. This leads to a NullPointerException.

To reconcile this issue, it is necessary to create a bundle and put it into one of the scoped variables. This can be done in a custom servlet or in a top level JSP page.

MessageResources bundle = MessageResources.getMessageResources("ApplicationMessages");
pageContext.setAttribute(Globals.MESSAGES_KEY, bundle, PageContext.REQUEST_SCOPE);If done in a custom servlet (and hence application scope) an empty ModuleConfig object must also be created and stuffed in the application scope.

ModuleConfig moduleConfig = new ModuleConfigImpl("");
moduleConfig.freeze();
getServletContext().setAttribute(Globals.MODULE_KEY, moduleConfig);Change Action.perform(...) to Action.execute(...)
In Struts 1.1 the execute(...) method was introduced and perform(...) method deprecated in  Action. In Struts 1.1 the deprecated perform(...) method continues to work.

In Struts 1.2.x the deprecated perform(...) method was removed from  Action and therefore any Action's which still implement perform(...) rather than execute(...) no longer function and should be changed to implement execute(...).
分享到:
评论

相关推荐

    linux基础进阶笔记

    linux基础进阶笔记,配套视频:https://www.bilibili.com/list/474327672?sid=4493093&spm_id_from=333.999.0.0&desc=1

    IMG20241115211541.jpg

    IMG20241115211541.jpg

    Sen2_ARI_median.txt

    GEE训练教程——Landsat5、8和Sentinel-2、DEM和各2哦想指数下载

    毕业设计&课设_基于 flask-whoosh-jieba 的代码,涉及文件管理及问题修复.zip

    该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过严格测试运行成功才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

    基于springboot家政预约平台源码数据库文档.zip

    基于springboot家政预约平台源码数据库文档.zip

    Ucharts添加stack和折线图line的混合图

    Ucharts添加stack和折线图line的混合图

    基于springboot员工在线餐饮管理系统源码数据库文档.zip

    基于springboot员工在线餐饮管理系统源码数据库文档.zip

    2015-2021年新能源汽车分地区、分类型、分级别销量逐月数据和进出口数据-最新出炉.zip

    新能源汽车进出口数据 1、时间跨度:2018-2020年 2、指标说明:包含如下指标的进出口数据:混合动力客车(10座及以上)、纯电动客车(10座及以上)、非插电式混合动力乘用车、插电式混合动力乘用车、纯电动乘用车 二、新能源汽车进出口月销售数据(分地区、分类型、分 级别) 1、数据来源:见资料内说明 2、时间跨度:2014年1月-2021年5月 4、指标说明: 包含如下指标 2015年1月-2021年5月新能源乘用车终端月度销量(分类型)部分内容如下: 新能源乘用车(单月值、累计值 )、插电式混合动力 月度销量合计(狭义乘用车轿车、SUV、MPV、交叉型乘用车); 月度销量同比增速(狭义乘用车轿车、SUV、MPV、交叉型乘用车); 累计销量合计(狭义乘用车轿车、SUV、IPV、交叉型乘用车); 累计销量同比增速(狭义乘用车轿车、SUV、MPV、交叉型乘用车); 累计结构变化(狭义乘用车轿车、SUV、IPV、交叉型乘用车); 2015年1月-2021年5月新能源乘用车终端月度销量(分地区)内容如下: 更多见资源内

    中心主题-241121215200.pdf

    中心主题-241121215200.pdf

    蓝奏云下载链接与密码整理

    内容概要:本文档提供了多个蓝奏云下载链接及其对应解压密码,帮助用户快速获取所需文件。 适合人群:需要从蓝奏云下载文件的互联网用户。 使用场景及目标:方便地记录并分享蓝奏云上文件的下载地址和密码,提高下载效率。 阅读建议:直接查看并使用提供的链接和密码即可。若遇到失效情况,请尝试联系上传者确认更新后的链接。

    Javaweb仓库管理系统项目源码.zip

    基于Java web 实现的仓库管理系统源码,适用于初学者了解Java web的开发过程以及仓库管理系统的实现。

    Python-文件重命名-自定义添加文字-重命名

    资源名称:Python-文件重命名-自定义添加文字-重命名 类型:windows—exe可执行工具 环境:Windows10或以上系统 功能: 1、点击按钮 "源原文"【浏览】表示:选择重命名的文件夹 2、点击按钮 "保存文件夹"【浏览】表示:保存的路径(为了方便可选择保存在 源文件中 ) 3、功能①:在【头部】添加自定义文字 4、功能②:在【尾部】添加自定义文字 5、功能③:输入源字符 ;输入替换字符 可以将源文件中的字符替换自定义的 6、功能④:自动加上编号_1 _2 _3 优点: 1、非常快的速度! 2、已打包—双击即用!无需安装! 3、自带GUI界面方便使用!

    JDK8安装包,为各位学习的朋友免费提供

    JDK8安装包

    Centos-7yum的rpm包

    配合作者 一同使用 作者地址没有次下载路径 https://blog.csdn.net/weixin_52372189/article/details/127471149?fromshare=blogdetail&sharetype=blogdetail&sharerId=127471149&sharerefer=PC&sharesource=weixin_45375332&sharefrom=from_link

    setup_python_geospatial_analysis.ipynb

    GEE训练教程

    毕业设计&课设_文成公主微信公众号全栈工程,含技术栈、架构及部署流程等内容.zip

    该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过严格测试运行成功才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

    基于springboot交通感知与车路协同系统源码数据库文档.zip

    基于springboot交通感知与车路协同系统源码数据库文档.zip

    基于springboot+vue 雅妮电影票购买系统源码数据库文档.zip

    基于springboot+vue 雅妮电影票购买系统源码数据库文档.zip

    使用 HTML5 实现拖放交互:音效与提示功能的完整实现

    为了更好地理解 HTML5 的拖放功能,我们设计了一个简单有趣的示例:将水果从水果区拖放到购物笼中,实时更新数量和价格,并在所有水果被成功放置后,播放音效并显示提示。

    毕业设计&课设_基于 SSM 的大学生综合成绩测评系统(含信息及数据库脚本,体现系统架构及功能设计).zip

    该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过严格测试运行成功才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

Global site tag (gtag.js) - Google Analytics