如何在struts2.xml文件中声明Generics Action?
我的问题是在Struts2操作中,
我有一个类:
public class MyAction<T> extends ActionSupport
带有这样的私有成员:
private T myData;
并且我想在struts.xml文件中声明这个aciton, 我怎样才能做到这一点?
感谢您的回答。
Ps:我尝试过不声明 T,但没有成功
My problems is in a Struts2 action, where
I have a class :
public class MyAction<T> extends ActionSupport
with a private member like this :
private T myData;
And I would like to declare this aciton in the struts.xml file,
how can i manage to do so ?
Thanks for the answer.
Ps : I've tried without declaration of T, but it did not work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
例如,您不能明显地编写(在 struts-XX.xml 中),
但您可以轻松地为您打算使用的每个参数化编写一个类(某种别名)。
进而 :
For example, you cannot obvioulsy write (in struts-XX.xml)
But you can easily code a class (sort of alias) for each parametrization you intend to use.
and then :
在 struts2 中,框架为每个请求实例化操作对象。,我认为它不允许这样做)
然后,我认为您不能为此使用参数化类。
(除非 struts 允许您为特定的操作映射指定特定的类参数化,例如 MyAction
In struts2 the action object is instantiated by the framework for each request.
Then, I don't think you can use a parametrized class for that.
(Except if struts allows you to specify a particular class parametrization, say MyAction<Date> , for a particular action mapping - I don't think it allows that)