Struts Action中的多个入口点(Migration Struts 2.2.3 – > 2.3.1)
我在struts.xml中有一个动作
reprint /x ${errorFlag} ${message} /jsp/reprintOverview.jsp
一个JSP:
有几个表单元素,都绑定到一个操作。 每个表单都有一个具有不同method
的单独提交按钮(例如“shopPdfReprint”)。 每个method
都映射到相应类中的方法。
Struts 2.2.3一切正常。 但是在迁移到2.3.1之后,方法映射不起作用。 而是调用相应的方法(例如“shopPdfReprint”),只调用类的execute
-method。
我看过Docs,但遗憾的是没有找到线索,如何适应2.3.1。有人遇到过这个吗? 感谢帮助:]
发生这种情况是因为您已关闭DMI。 即使在重新发送安全修复程序之后, method
属性也像以前一样使用submit标记。 使用常量启用DMI
如果它不起作用,请告诉我。
如果有人正在移动或使用Struts 2.5,那么他们不必使用struts.xml映射动作。 Strtus 2.5是基于注释的,因此在动作类开发人员可以使用注释在单个类中映射多个动作。
可能是这个链接有用,从旧的struts版本到struts 2.5版本。
https://struts.apache.org/docs/struts-23-to-25-migration.html
以下是简单的演示代码。
package com.stsh.action; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; import org.apache.struts2.convention.annotation.Result; import com.opensymphony.xwork2.ActionSupport; import com.stsh.intercepter.AuthRequired; @ParentPackage(value="default") @Namespace(value="/dashboard") public class DashboardAction extends ActionSupport implements AuthRequired{ private static final long serialVersionUID = 1L; @Action(value = "home", results = { @Result(name = "success", location = "dashboard.tiles", type = "tiles") }) public String dashboard(){ return "success"; } }