niklassaers
niklassaers

Reputation: 8830

JSON and XML from Roo RESTful controllers

I've got my Spring Roo project set up and it's all great, but the views are rendered with Tiles, and I'd love to have them just rendered to JSON (possibly to XML) so that I can use them directly as webservices. Do you have any suggestions to how I should do this "the Roo way"?

Cheers

Nik

Upvotes: 3

Views: 6333

Answers (5)

H6_
H6_

Reputation: 32857

For JSON support you can find at springsource.org some introduction.

It's mainly activating JSON support for the domain entities via

json all 

or

json add

and then setting up the MVC controllers via the following roo command:

web mvc json all 

Upvotes: 0

lotfi
lotfi

Reputation: 425

I do this kind of project and it's worked very well. So you need to use the following steps to achieve your project:

1-Create your Spring Roo project

2-The roo shell will be opened for your project

3-In the Roo shell, try to use this liste of commands in the order:

a-- project --topLevelPackage your package--projectName

b-- osgi start --url the path of your jdbc (file:////home/binov1/workspaceLiferay/postgresql-9.4-1201.jdbc4.jar -- it's my jdbc path)

c-- jpa setup --provider HIBERNATE --database POSTGRES --hostName adresse --userName your user name --password your password --databaseName name of your database

d-- database reverse engineer --schema public --package your package.

e-- json all

f-- web mvc json setup

g-- web mvc json all

This solution will help you very well, try it

Upvotes: 1

Stefan De Boey
Stefan De Boey

Reputation: 2394

take a look at the ContentNegotiatingViewResolver

there's a similar question on the Spring forums.

Upvotes: 1

Alex McLintock
Alex McLintock

Reputation: 169

This may help...

http://www.youtube.com/watch?v=TNE7NBLseRA RESTful Web Services with Spring Roo

"In this screencast, we continue our exploration of tools and frameworks supporting RESTful Web Services by taking a look at Spring Roo. We'll use our example Dictionary service that we've used in the past. We'll use Roo's JSON support to implement the GET, PUT, POST, and DELETE operations on the Word resource."

Upvotes: 1

tzolov
tzolov

Reputation: 601

You can use RooAddon that setup the content negotiation for you: http://tzolov.blogspot.com/2010/05/spring-roo-addons-jaxb2-binding-and.html

Upvotes: 0

Related Questions