如何在struts2.xml文件中声明一个泛型操作? [英] How to declare a Generics Action in struts2.xml file?
本文介绍了如何在struts2.xml文件中声明一个泛型操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是在Struts2 操作中,其中
My problems is in a Struts2 action, where
我有一个类:
public class MyAction<T> extends ActionSupport
private T myData;
我想在 struts.xml 文件中声明这个aciton ,
我如何设法这么做?
And I would like to declare this aciton in the struts.xml file, how can i manage to do so ?
感谢您的回答。
Ps:我尝试过不用T的声明,但它没有工作
Ps : I've tried without declaration of T, but it did not work
推荐答案
例如,您不能在objs中写入(在struts-XX.xml中)
For example, you cannot obvioulsy write (in struts-XX.xml)
<action name="doSomething" class="xx.xx.MyAction<java.util.Date>">
但是,您可以轻松地为您打算使用的每个参数化编写一个类(别名)。
But you can easily code a class (sort of alias) for each parametrization you intend to use.
public class MyAction_Date extends MyAction<java.util.Date> {}
然后:
and then :
<action name="doSomething" class="xx.xx.MyAction_Date">
这篇关于如何在struts2.xml文件中声明一个泛型操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文