Struts 替代 Spring MVC 模型
嘿, 我正在使用 Spring MVC,并且习惯于“发送”DTO 到视图而不直接填充 servlet 请求,这是非常灵活和有效的。我正在尝试弄清楚如何在 Struts 中执行类似的操作,因为据我所知,“发送”DTO 进行查看的唯一方法是通过请求调度程序,其中 servlet 请求以键值样式填充 DTO由程序员手动操作。
与 Spring MVC 相比,这导致视图层 (JSP) 中有太多逻辑。
这是 DTO 从处理程序传输到视图层的唯一方法吗?
Hey,
I'm using Spring MVC and I got used to "sending" DTO to a view without populating servlet request directly, which is very flexible and effective. I'm trying to figure out how to do something similar in Struts, because as far as I can see, the only way how to "send" DTO to view is via request dispatcher where servlet request is populated with DTOs in key - value style manually by programmer.
This results in having too much logic in view layer (JSPs) in comparison with Spring MVC.
Is this the only way of DTO transfer from handlers to a view layer ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,我在 Struts 中看到的完成方式是通过 Form 对象。该表单类扩展了 ActionForm。然后在 struts-config.xml 中将此表单定义为表单 bean。然后在操作类 bean 定义中添加对表单 bean 的引用。然后在 jsp 中重新引用表单以从 DTO 获取数据。
例如:-
Generally the way I have seen it being done in Struts is via Form objects. This form class extends ActionForm. Then in the struts-config.xml you define this form as a a form bean. Then add a reference to the form bean in the action class bean definition. Then in the jsp you rerefence the form to get data from the DTO.
For example:-