Struts 1 到 Struts 2 迁移策略 [英] Struts 1 to Struts 2 migration strategy

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

问题描述

如果我想将 Struts 1 迁移到 Struts 2,是否可以将 JSP 实现留在 Struts 1 中并在 Struts 2 中重写 action 类?

If I want to migrate Struts 1 to Struts 2, can I leave the JSP implementation in Struts 1 and rewrite the action class in Struts 2?

我可以在 web.xml 中同时使用 Struts 1 和 Struts 2 的配置吗?

Can I use in web.xml both configurations for Struts 1 and Struts 2?

推荐答案

你必须重写动作类和 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.

如果您需要有关迁移过程的更多信息,可以阅读this 答案.但是,与最新版本的 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.

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

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