2

I would like to create a REST-like url mapping on Google App Engine with Java. The difficulty is that I want to use the following URL mapping:

/users -> UserListServlet
/users/4547 -> UserServlet
/users/3422/posts -> PostListOfUserServlet
/users/5433/posts/1234 -> PostOfUserServlet

But according to the manual (http://www.roguewave.com/portals/0/products/hydraexpress/docs/3.5.0/html/rwsfservletug/4-3.html), in the web.xml I can only have one wildchar at the end of the URL, so I can map to /users and /users/*, but I can't map to /users/*/posts and /users/*/posts/*.

What is the easy and conventional way to separate these cases and get the parameters, are there good practices, or I must create a servlet what gets all /users/* requests and then split it at "/" characters and manually pass them to the different servlets?

4

1 回答 1

1

Consider using a REST framework like RESTEasy. Others have deployed it successfully on GAE.

Other options include Spring MVC and Restlet.

All of them will abstract away the low level details of the Servlet API and let you focus on your services.

于 2013-10-13T21:22:05.223 回答