Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>here simple code which call amazon.java rest class when its match with url as <a href="http://anydomain.com/amazone" rel="nofollow">http://anydomain.com/amazone</a> if you hit this in url than its called get method</p> <pre><code>public class RestApi extends Application { /** * Creates a root Restlet that will receive all incoming calls. */ @Override public Restlet createInboundRoot() { Router router = new Router(getContext()); // Defines only one route router.attach("/amazon", Amazon.class); return router; } } </code></pre> <p>amazon.java</p> <pre><code>public class Amazon extends ServerResource { @Override protected Representation post(Representation entity) throws ResourceException { System.out.println("post Method"); return super.post(entity); } @Override protected Representation get() throws ResourceException { System.out.println("get method"); return super.get(); } } </code></pre> <p>and mapping in web.xml file as</p> <pre><code> &lt;servlet&gt; &lt;servlet-name&gt;RestletServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.restlet.ext.servlet.ServerServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;org.restlet.application&lt;/param-name&gt; &lt;param-value&gt;com.wa.gwtamazon.server.RestApi &lt;/param-value&gt; &lt;/init-param&gt; </code></pre> <p></p> <pre><code>&lt;!-- Catch all requests --&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;RestletServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload