如何使用spring MVC创建REST Web服务以用于后端目的? [英] How do I create REST webservice using spring MVC for backend purpose?

查看:113
本文介绍了如何使用spring MVC创建REST Web服务以用于后端目的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Spring MVC架构的新手,想要创建后端,后端与数据库交互,我可以从网站和Android应用程序访问它。以下是我对Spring MVC的理解 -

*模型(getter-setter类)

*服务(包含数据库中所有表的CRUD方法的类)

* REST控制器(每个服务类一个)



以上三点是否正确?

如果是,则比另外几个问题在我看来,如何在Spring MVC使用的网站和android中访问相同的Model(getter-setter)类,因为这些类用于将数据从视图传输到REST控制器。 br />
还必须为每个服务类创建单独的REST控制器吗?由于我的数据库包含50个表,因此我必须创建50个服务类和50个REST控制器类。这听起来不是一团糟吗?我认为我没有走上正轨。请解释一下我如何制作可在Android应用程序和网站上访问的后端的整个场景。



提前致谢。



我尝试了什么:



我在网上搜索过这个问题,并且有到目前为止还没有找到任何可靠的解决方案或理解。

I am new to Spring MVC architecture and want to create backend, which interacts with database and which I can access it from website and android app. Following is my understanding till now for Spring MVC -
* Model (getter-setter classes)
* Service (classes containing CRUD methods for all tables in database)
* REST controller (one for each service class)

Are the above three points correct?
If yes, than another few issues strike in my mind, that how to access same Model (getter-setter) classes in both website as well as android, which are used by Spring MVC, as these classes are used to transfer data from view to REST controller.
Also is it mandatory to create separate REST controller for each service class? As my database contains 50 tables, than I have to create 50 service classes and 50 REST controller classes. Isn't this sounds something mess? I think am not on the right track. Please explain me whole scenario as to how can I make backend which can be accessed in both android app as well as website.

Thanks in advance.

What I have tried:

I have searched for this issue on internet, and have not found any reliable solution or understanding so far.

推荐答案

你究竟搜索了什么?请参阅创建rest spring mvc - Google搜索 [ ^ ]。
What exactly did you search for? See create rest spring mvc - Google Search[^].


这篇关于如何使用spring MVC创建REST Web服务以用于后端目的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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