Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

java - Need to implement RESTful web services in Struts2 and Spring

I am currently working on a web application that is based on Strtus2, Spring, open JPA and LDAP.

Now client wants us to develop RESTful api for this system so that other websites or application can integrate with it.

This task has been assigned to me and I clearly have no idea from where to start.

I have done my research and found out that, there is a plugin struts2-rest and for Spring there are several different ways.

More to that most of the example I have been seen are using Maven, but our project does not use that.

So, I just need a direction to start this thing.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Struts2 you can implement RESTful api via struts2-rest-plugin. The starting point is 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.


In the Home of Struts2 docs you'll find everything necessary to start developing Struts2 application.

Resources:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...