Can I merge these two web applications to become o

2019-08-11 06:32发布

问题:

I have started to write two web application projects

  • RESFful API for mobile clients using Spring REST API
  • GWT WebApp Server for web clients using Servlets

My problem is that both web applications are using the same database and that I think that instead of having two web applications I actually should have started this project using just one web application that handles the requests for web and mobile clients.

The problem I got now is that I don't have any idea how I could "merge" those two guys and whether I should stick to Spring REST API or if I should use RestyGWT.

GWT Server-Project using Servlets

RESTful Server using Spring

All projects (in the middle of a major refactoring mission)

Is there a way that would allow me to launch the web application as a whole and have access to the REST API from my mobile clients and to the Servlets from my web clients?

回答1:

It depends on your business logic implementation. If you have it in a separate module/package, then it should be easy to merge your two applications.

You will have to rework the mappings in web.xml and how you pass the input/output data to the business logic methods from both the REST implementation and your servlet code.

Personally I will recommend a single approach such as only going with the REST based approach that you already have and migrate your servlet functionality to it.