Struts1 to Struts2 migration strategy

旧巷老猫 提交于 2020-01-11 07:20:30

问题


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

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


回答1:


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.

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 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.

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.



来源:https://stackoverflow.com/questions/42580831/struts1-to-struts2-migration-strategy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!