需要在 Struts2 和 Spring 中实施 RESTful 网络服务

Need to implement RESTful web services in Struts2 and Spring

我目前正在开发基于 Strtus2 的 Web 应用程序,Spring,打开 JPA 和 LDAP。

现在客户希望我们为这个系统开发RESTful api,以便其他网站或应用程序可以与它集成。

这个任务已经分配给我了,我显然不知道从哪里开始。

我做了研究,发现有一个插件 struts2-rest,对于 Spring 有几种不同的方法。

更重要的是,我看到的大多数示例都使用 Maven,但我们的项目没有使用它。

所以,我只需要一个开始这件事的方向。

在 Struts2 中,您可以通过 struts2-rest-plugin 实现 RESTful api。起点是REST Plugin.

Setting Up

Assuming you have a normal Struts 2 application, all you need to do for this REST demo is to add the following two plugins:

Struts 2 Rest Plugin
Struts 2 Convention Plugin

Note, you can download the jars for these plugins from Maven Central Configuration ( struts.xml )

Just dropping the plugin's into your application may not produce exactly the desired effect. There are a couple of considerations. The first consideration is whether you want to have any non-RESTful URL's coexisting with your RESTful URL's. We'll show two configurations. The first assumes all you want to do is REST. The second assumes you want to keep other non-RESTful URL's alive in the same Struts 2 application.


在 Struts2 文档的 Home 中,您将找到开始开发 Struts2 应用程序所需的一切。

资源: