struts2:从类型转换器访问外部服务
是否可以将服务引用注入自定义类型转换器?
事实上,我的情况非常典型,我有一个组合,它绑定到实体的集合。提交时,我仅获得所选实体的 ID,并且必须在我的操作中重新获取真实对象。我正在考虑更优雅的方法来做到这一点,似乎制作一个可以执行获取的 ID 到实体的自定义转换器 - 将是一个好主意。
但我未能尝试以与操作相同的方式将转换器映射到 Spring bean...
is it possible to inject a service reference into custom type converter?
my situation is quite typical in fact, I have a combo, which binds to collection of entities. On submit I get only an ID of selected entity and have to refetch the real object in my action. I was thinking about more elegant way to do this, and it seems like making an ID-to-entity custom converter which would perform fetching - would be a good idea.
But I failed trying to map a converter to Spring bean in the same fashion like actions...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有趣的问题。您是否使用 spring 插件 ?
它应该负责 Struts2 的服务对象创建(以及与其他服务的连接),并且应该能够包括类型转换器。来自此处:
,但我还没有使用过该功能。
Interesting question. Are you using the spring plugin ?.
It is supposed to take care of service-objects creation, (and wiring with other services) for Struts2, and this should be able to include Type Converters. From here:
But I have not used that feature.