Struts 2 总是需要 conversion.properties 文件吗?
我正在阅读《Struts 2 In Action》,在第五章中,创建了一个 conversion.properties 文件来演示多值参数的数据传输。它包括这一行:
Element_weights=java.lang.Double
并且有一个在 Action 类中不使用泛型的列表:
List weights;
我用 just 替换了所有这些
List<Double> weights;
,并且类型转换似乎工作得很好。使用泛型有什么缺点吗?这本书的作者这样做有什么原因吗?
编辑:我一直在阅读,事实上,仿制药是有效的,作者甚至推荐它。尽管如此,为什么他们一开始就没有使用它仍然让我困惑。
I'm reading Struts 2 In Action, and, on the chapter five, a conversion.properties file is created to demonstrate data transfer for multivalued parameters. It includes this line:
Element_weights=java.lang.Double
And there's a list that does not use generics in the Action class:
List weights;
I replaced all this with just
List<Double> weights;
and the type conversion seemed to work just fine. Are there any drawbacks to using generics, any reason for what the authors of the book are doing?
edit: I kept reading and, in fact, generics work, and the authors even recommend it. Why they haven't used it in the first place still puzzles me, nevertheless.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些类型的转换条目仅在前泛型环境中需要。如果可能的话,绝对使用泛型。
Those types of conversion entries are only needed in pre-generics environments. Definitely use generics if at all possible.