Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC Struts Mixing

This is really a general question.

I have an ecommerce webapp that I built solo about 4 years ago. At the time, I made the decision to use Struts as my mvc framework. As years passed working on other projects, I came to appreciate and feel much more comfortable with the feature set and flexibility offered by Spring MVC.

The service layer is solid, and is built using the spring framework.

I'd like to refactor my current web layer to now use Spring MVC. But as I have mentioned previously, I wrote the app solo and it's more of a side project. The point being that I do not have time, nor do I want to risk throwing away and completely reengineering the web layer from scratch.

So I'm asking the community on what their strategy would be for this refactoring effort?

Ideally, I would like to tackle pieces at a time, and ultimately mix the two technologies until eventually when I can completely turn off Struts.

All new functionality for my site would best be developed in Spring MVC.

The good thing is that my existing views, which is currently using apache tiles, would not have to change much, with the exception of removing struts tag libraries and replacing them with Spring MVC.

One requirement I'd like to keep is that the URL's should not change.

In other words, the ActionServlet and the DispatcherServlet would have to map to separate paths but somehow go to different implementations.

For example, how can I say that mysite.com/show-product maps to a Spring Dispatcher servlet, but mysite.com/show-category maps to a Struts action servlet.

Your thoughts are appreciated.

like image 233
Roy Kachouh Avatar asked Nov 14 '22 12:11

Roy Kachouh


1 Answers

You can run them both in the same container with appropriate mapping.

I don't understand the question "should I convert action classes to spring controllers one at a time", how else would you do it?

Whether an action class should map to a method of a controller has more to do with your existing app's organization than anything else, or at least how you want the Spring app organized.

like image 128
Dave Newton Avatar answered Nov 16 '22 02:11

Dave Newton