从Struts1到Struts2的迁移策略 [英] Struts1 to Struts2 migration strategy

查看:341
本文介绍了从Struts1到Struts2的迁移策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要将Struts1迁移到Struts2,可以将JSP实现保留在Struts1中,而将动作类重写在Struts2中吗?

If you want to migrate Struts1 to Struts2, you can leave the JSP implementation in Struts1 and rewrite the action class in Struts2?

您可以在web.xml中添加Struts1和Struts2的两种配置吗?

Can you add in web.xml both configurations for Struts1 and Struts2?

推荐答案

您必须同时重写操作类和JSP,但是如果服务层中存在业务服务,则可以重用它们.持久层也是如此.

You have to rewrite both action classes and JSP, however you can reuse your business services if they are exist on the service layer. The same is for persistence layer.

注意,如果可以保留JSP实现,则应将其替换为可在视图层上使用的东西.它可以是html,javascript,另一个模板框架,例如freemarker或Velocity.它可以是通过HTTP或Web套接字与服务器通信的SPA或MPA应用程序.由您决定如何构建应用程序. Struts可以在插件支持下解析常用的HTTP请求(GET/POST)和REST.有许多插件可以帮助您更好地使用该框架.

Note, if you can leave JSP implementation, then you should replace them with something that will work on the view layer. It could be html, javascript, another templating framework like freemarker or velocity. It could be SPA, or MPA application that communicates with the server via HTTP or web sockets. It's up to you how do you architect your application. Struts can parse usual HTTP requests (GET/POST) and REST with support of the plugin. A lot of plugins exist to help you to better use the framework.

Struts1太旧了,不能与最新的Struts2一起使用,因为它们的不同版本的依赖项不匹配.您应该只离开Struts1并将其迁移到Struts2.这是一个简单的过程,只需花费更少的时间,而无需重写到诸如Spring MVC的另一个框架.

Struts1 is too old and can't work with the latest Struts2 because they have mismatch of dependencies of different versions. You should just leave Struts1 and migrate it to Struts2. It's straightforward process that takes less time rather that rewriting to another framework like Spring MVC.

如果您需要有关迁移过程的更多信息,可以阅读答案.但是,与最新版本的Struts相比,许多信息和代码已经过时,并且可能无法正常工作,但想法仍然相同.

If you need more information about the migration process you can read this answer. However, a lot of information and code is already outdated comparing to the latest version of Struts and might not work the ideas remain the same.

这篇关于从Struts1到Struts2的迁移策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆