Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Content Types

In addition to being a REST-style URL mapper, this plugin provides built-in support for multiple content types, switchable through the URL extension. In this way, a single resource can be exposed as multiple content types without any extra work.For example, by exposing an "orders" resource, clients can immediately access it via:providing mapping of RESTful URL's to Controller ( Action ) invocations, the REST plugin also provides the ability to produce multiple representations of the resource data. By default, the plugin can return the resource in the following content types:

*HTML
*XML
*JSON

There is nothing configure here, just add the conent type extension to your RESTful URL. The framework will take care of the rest. So, for instance, assuming a Controller called Movies and a movie with the id of superman, the following URL's will all hit the

Code Block
http://my.company.com/myapp/ordersmovies/1superman
http://my.company.com/myapp/ordersmovies/1superman.xml
http://my.company.com/myapp/ordersmovies/1superman.xhtml
http://my.company.com/myapp/ordersmovies/1superman.json

...

Note

Note, these content types are supported as incoming data types as well. And, if you need, you can extend the functionality by writing your own implementations of org.apache.struts2.rest.handler.ContentTypeHandler and registering them with the system.

Usage

This section will walk you through a quick demo.

...