path-parameter

Accept comma separated value in REST Webservice

点点圈 提交于 2019-12-05 15:59:23
I am trying to receive a list of String as comma separated value in the REST URI ( sample : http://localhost:8080/com.vogella.jersey.first/rest/todo/test/1/abc,test , where abc and test are the comma separated values passed in). Currently I am getting this value as string and then splitting it to get the individual values. Current code : @Path("/todo") public class TodoResource { // This method is called if XMLis request @GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Path("/test/{id: .*}/{name: .*}") public Todo getXML(@PathParam("id") String id, @PathParam("name")

What is the difference between @PathParam and @PathVariable

有些话、适合烂在心里 提交于 2019-12-03 18:45:46
问题 To my knowledge both serves the same purpose. Except the fact that @PathVariable is from Spring MVC and @PathParam is from JAX-RS. Any insights on this? 回答1: @PathVariable and @PathParam both are used for accessing parameters from URI Template Differences: As you mention @PathVariable is from spring and @PathParam is from JAX-RS. @PathParam can use with REST only, where @PathVariable used in Spring so it works in MVC and REST. 回答2: PathParam: To assign URI parameter values to method arguments

What is the difference between @PathParam and @PathVariable

霸气de小男生 提交于 2019-11-30 01:22:29
To my knowledge both serves the same purpose. Except the fact that @PathVariable is from Spring MVC and @PathParam is from JAX-RS. Any insights on this? @PathVariable and @PathParam both are used for accessing parameters from URI Template Differences: As you mention @PathVariable is from spring and @PathParam is from JAX-RS . @PathParam can use with REST only, where @PathVariable used in Spring so it works in MVC and REST. PathParam: To assign URI parameter values to method arguments. In Spring, it is @RequestParam . Eg., http://localhost:8080/books?isbn=1234 @GetMapping("/books/") public Book

Store @PathParam values from REST call in a list or array

邮差的信 提交于 2019-11-29 02:42:32
My function looks like this: @PUT @Path("property/{uuid}/{key}/{value}") @Produces("application/xml") public Map<String,ValueEntity> updateProperty(@Context HttpServletRequest request, @PathParam("key") String key, @PathParam("value") String value, @PathParam("uuid") String uuid) throws Exception { ... } I have to modify it, so it accepts indefinite(or many) list of key-value pairs from REST call, something like @Path("property/{uuid}/{key1}/{value1}/{key2}/{value2}/{key3}/{value3}/...") Is it possible to store them in an array or list, so I do not list dozens of @PathParams and parameters, to

Wildcard path for servlet?

大城市里の小女人 提交于 2019-11-27 21:36:49
Having an @WebServlet(urlPatterns = "/myServlet/") . If the user goes to myapp/myServlet/other , I still want my servlet to catch. So to say, wildcard anything on after the servlet path. How could I do this? BalusC You can use * as prefix or suffix wildcard. In your case, you can use /myServlet/* for a folder mapping. @WebServlet("/myServlet/*") The path info (the part after the mapping in the URL) is in the servlet by the way available as: String pathInfo = request.getPathInfo(); This would in case of myapp/myServlet/other return /other . See also: Servlet and path parameters like /xyz/{value

Store @PathParam values from REST call in a list or array

六眼飞鱼酱① 提交于 2019-11-27 16:59:46
问题 My function looks like this: @PUT @Path("property/{uuid}/{key}/{value}") @Produces("application/xml") public Map<String,ValueEntity> updateProperty(@Context HttpServletRequest request, @PathParam("key") String key, @PathParam("value") String value, @PathParam("uuid") String uuid) throws Exception { ... } I have to modify it, so it accepts indefinite(or many) list of key-value pairs from REST call, something like @Path("property/{uuid}/{key1}/{value1}/{key2}/{value2}/{key3}/{value3}/...") Is

Servlet and path parameters like /xyz/{value}/test, how to map in web.xml?

*爱你&永不变心* 提交于 2019-11-26 04:54:23
Does servlet support urls as follows: /xyz/{value}/test where value could be replaced by text or number. How to map that in the web.xml? It's not supported by Servlet API to have the URL pattern wildcard * in middle of the mapping. It only allows the wildcard * in the end of the mapping like so /prefix/* or in the start of the mapping like so *.suffix . With the standard allowed URL pattern syntax your best bet is to map it on /xyz/* and extract the path information using HttpServletRequest#getPathInfo() . So, given an <url-pattern>/xyz/*</url-pattern> , here's a basic kickoff example how to

Servlet and path parameters like /xyz/{value}/test, how to map in web.xml?

霸气de小男生 提交于 2019-11-26 03:28:39
问题 Does servlet support urls as follows: /xyz/{value}/test where value could be replaced by text or number. How to map that in the web.xml? 回答1: It's not supported by Servlet API to have the URL pattern wildcard * in middle of the mapping. It only allows the wildcard * in the end of the mapping like so /prefix/* or in the start of the mapping like so *.suffix . With the standard allowed URL pattern syntax your best bet is to map it on /xyz/* and extract the path information using