使用 Spring Boot 从 Struts 到 Spring MVC
我需要使用Spring Boot将Struts应用程序转换为Spring MVC。
他想要一个可以从两个不同的前端调用的应用核心,一个是角度,一个与JSP一起使用。
我的想法是构建和应用程序从肥皂服务或具有中央控制器的数据库中检索数据(揭示方法的常规Java类),将此应用程序的JAR导入两个不同的应用程序,一个带有@RestController < /代码>与Angular通信,并且与JSP一起使用的
@controller
。
现在,我知道如何使用REST服务和Angular构建Springboot应用程序,这样就不会打扰我。我担心与JSP一起使用Spring Boot。我不知道Struts,并且已经看到它具有创建JSP几乎将JSP的结构作为布局,例如“ header”
,“ footer” and cod>和ECC。现在。
我的问题现在是以一种非常有效的方式处理另一个前端(具有JSP的另一端)的最佳方法是什么?我从未使用过带有Spring的JSP,并且我了解了一些简单的“ Helloworld”
应用程序的基本配置。
I need to convert a Struts app to Spring MVC using Spring Boot.
He want one application Core that can be called from two different Front Ends, one is with Angular and one with JSPs.
My idea is to build and app that retrieve data from a Soap service or a database with a central Controller (normal java class that expose methods), import the Jar of this App in two different Apps, one with a @RestController
that communicate with Angular, and one with a @Controller
that works with JSPs.
Now I know how to build a springboot app using rest services and Angular so that doesn't bother me. I'm worried about using Spring Boot with JSPs. I didn't know Struts and I've seen that it has a structure for create JSP pretty much handiling JSPs as layouts like "Header"
, "Footer"
and ecc.. now in Angular I do the same thing with the components and is way more efficient, but JSPs are old and i found that very intresting.
My question is now what is the best way to handle the other Front End (the one with JSPs) in a pretty efficient way? I never used JSPs with Spring and I've understood the basic configuration doing some excercise with some easy "HelloWorld"
apps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我了解,Struts是一个纯净的MVC框架,而Spring MVC只是弹簧模块之一。我还听说他们使用它们的组合。
我必须立即说,Struts 1.2已经很长时间没有开发,并且已从Apache网站上删除。它的继任者是新名称的Webwork或Struts2。据我了解,如果名称已更改,则架构已经改变,这两个框架都非常不同。
Spring MVC 是一个网络框架,是弹簧模块之一。它使用MVC1实现如Struts 1。该框架的最大好处是,它可以轻松地与开发项目所需的其他弹簧模块集成。
struts2 是实现MVC2的基于servlet的Web框架。它可以用插件扩展,并集成到其他框架中,包括春季。
我认为,区别是什么,即使不是在建筑中,第一个的区别更简单,需要更少的学习时间。第二个更大,更复杂,需要更多的时间学习。显然,学习花费的时间然后有所回报。至于发展速度,我认为第二个发展速度更快。
Apache Struts 2.5.30 GA已发布
在2022年4月4日。
两个框架都可以在前端和后端上使用。如果您有一个问题使用什么,或者最好使用什么,那么我会马上告诉您,这是您的选择,而不仅仅是您的选择。许多人使用第一个框架,因为它是春季的一部分。如果您想快速完成简单的项目,那么第一个项目更适合您,但是如果您有更多的时间和机会来学习第二个框架,那么这可能会适合您。我通常无法想象如果不整合到春季的情况下,第二次使用的实际用途,但这同样是我个人的看法。
Struts, as I understand it, is a pure MVC Framework, and Spring MVC is just one of the Spring modules. I also heard that they use combinations of them.
I must say right away that Struts 1.2 has not been developed for a long time and has been removed from the Apache site. Its successor was WebWork or Struts2 in the new name. As I understand it, if the name has changed, then the architecture has changed, which is very different for both frameworks.
Spring MVC is a web framework that is one of the Spring modules. It uses the MVC1 implementation as in Struts 1. The greatest benefit of this framework is that it easily integrates with other Spring modules that you need to develop your project.
Struts2 is a servlet-based web framework that implements MVC2. It can be extended with plugins and integrated into other frameworks, including Spring.
What is the difference, if not in architecture, then the first one, in my opinion, is simpler and requires less time to learn. The second one is much larger and more complex, requiring much more time to learn. It is clear that the time spent on studying then pays off. As for the speed of development, the second one, in my opinion, is developing much faster.
Apache Struts 2.5.30 GA has been released
on 04 April 2022.
Both frameworks can be used both on the frontend and on the backend. If you have a question what to use, or what is better to use, then I will tell you right away that this is your choice, and not only yours. Many people use the first framework because it is part of Spring. If you want to get your simple project done quickly, then the first one is more suitable for you, but if you have more time and opportunity to spend on learning the second framework, then this may suit you. I generally can’t imagine the practical use of the second without integrating into Spring, but again, this is my personal opinion.
要处理Struts JSP,您需要以这种方式将所有支柱标签转换为兼容的JSTL或弹簧标签,您将能够将其用作弹簧MVC上的视图。
请参阅此帖子,还请查看GitHub代码: https://www.shorterpost.com/2021/03/how-to-contervert-truts-tags-tags-to-jstl-spring.html
附带的摘录摘自ShorterPost:
在githibub on glithub on giithub on giThub对于完整代码单击此处...
To handle struts jsp, you need to convert all struts tags into compatible jstl or spring tags in that way you will be able to use it as view on your spring mvc.
Please refer to this post and also checkout the github code: https://www.shorterpost.com/2021/03/how-to-convert-struts-tags-to-jstl-spring.html
Attached excerpt from shorterpost:
Check out on GitHub for full code Click Here...