jax-rs

How to enable strict type parsing for jackson?

ε祈祈猫儿з 提交于 2021-02-07 12:52:15
问题 Jackson 1.9.9 is somewhat inconsistent in what it parses into scalar values (bool, int, string). Any array or object type fails but you can put any scalar type into a string. For bool 0 and not 0 are mapped to false/true. int attributes accept only numbers. public class Foo { public String s; public boolean b; public int i; } ObjectMapper mapper = new ObjectMapper(); System.out.println(mapper.readValue("{\"s\":\"abc\"}", Foo.class).s); // "abc" System.out.println(mapper.readValue("{\"s\":true

How to enable strict type parsing for jackson?

折月煮酒 提交于 2021-02-07 12:52:13
问题 Jackson 1.9.9 is somewhat inconsistent in what it parses into scalar values (bool, int, string). Any array or object type fails but you can put any scalar type into a string. For bool 0 and not 0 are mapped to false/true. int attributes accept only numbers. public class Foo { public String s; public boolean b; public int i; } ObjectMapper mapper = new ObjectMapper(); System.out.println(mapper.readValue("{\"s\":\"abc\"}", Foo.class).s); // "abc" System.out.println(mapper.readValue("{\"s\":true

JAX-RS with Jersey: Passing form parameters to PUT method for updating a Resource

时光毁灭记忆、已成空白 提交于 2021-02-07 03:35:49
问题 I have to update a Person record having firstName and lastName. User should be able to change it from html form and on submit it should be updated. Here is my code. @PUT @Path("/{userId}") public Response updatingResource(@FormParam("firstName") String firstName, @FormParam("lastName ") String lastName , @PathParam("userId") String userId){ System.out.println(firstName); System.out.println(lastName); return Response.ok().build(); } the SOP statements prints null. I have been using Mozilla

JAX-RS with Jersey: Passing form parameters to PUT method for updating a Resource

こ雲淡風輕ζ 提交于 2021-02-07 03:31:23
问题 I have to update a Person record having firstName and lastName. User should be able to change it from html form and on submit it should be updated. Here is my code. @PUT @Path("/{userId}") public Response updatingResource(@FormParam("firstName") String firstName, @FormParam("lastName ") String lastName , @PathParam("userId") String userId){ System.out.println(firstName); System.out.println(lastName); return Response.ok().build(); } the SOP statements prints null. I have been using Mozilla

JAX-RS with Jersey: Passing form parameters to PUT method for updating a Resource

浪尽此生 提交于 2021-02-07 03:29:41
问题 I have to update a Person record having firstName and lastName. User should be able to change it from html form and on submit it should be updated. Here is my code. @PUT @Path("/{userId}") public Response updatingResource(@FormParam("firstName") String firstName, @FormParam("lastName ") String lastName , @PathParam("userId") String userId){ System.out.println(firstName); System.out.println(lastName); return Response.ok().build(); } the SOP statements prints null. I have been using Mozilla

404 on JAX-RS on Tomcat, MBeans?

巧了我就是萌 提交于 2021-01-29 18:11:59
问题 I'm getting a 404 on a JAX-RS request, but am running out of things to try out of my bag of tricks. Simplified code where service is defined: package mypackage; @Path("/") public class SavedQueriesService { ... @POST @Path("saved_queries") @Consumes(MediaType.APPLICATION_JSON) @Produces({ MediaType.APPLICATION_JSON + AppConstants.COMMA + MediaType.CHARSET_PARAMETER + AppConstants.UTF_8 }) public Response saveNewSavedQuery(@Context HttpServletRequest httpServletRequest, SavedQueryRequest

Custom hostname resolver for JAX-RS client

南楼画角 提交于 2021-01-29 12:22:21
问题 Is there a way to customize the host name resolution inside a JAX-RS client? I am using javax.ws.rs.client.ClientBuilder to create a client and I would like that for example https://mytestinghost.tech resolves mytestinghost.tech to an IP I can define; e.g. 1.2.3.4 . I am either using default connector or Jetty HTTP(2) connector. The client is retrieved using the following code. ClientBuilder.newBuilder() .trustStore(clientCertificateProvider.getCertificate()) .withConfig(new ClientConfig()

Jersey JAX-RS application returns 404

≡放荡痞女 提交于 2021-01-29 11:47:42
问题 Everytime I run the application on server and enter the url I don't get any response. It says the following (image): Java code is as follows: package application; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.ws.rs.GET; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.Path; import javax.ws.rs.core.Application; import javax.ws.rs.ApplicationPath; @Path("demo") public class FRITZ { @GET @Produces

Custom hostname resolver for JAX-RS client

断了今生、忘了曾经 提交于 2021-01-29 09:44:05
问题 Is there a way to customize the host name resolution inside a JAX-RS client? I am using javax.ws.rs.client.ClientBuilder to create a client and I would like that for example https://mytestinghost.tech resolves mytestinghost.tech to an IP I can define; e.g. 1.2.3.4 . I am either using default connector or Jetty HTTP(2) connector. The client is retrieved using the following code. ClientBuilder.newBuilder() .trustStore(clientCertificateProvider.getCertificate()) .withConfig(new ClientConfig()

Spring Boot/Kotlin ignore value field of @QueryParam

梦想与她 提交于 2021-01-29 05:44:00
问题 I have a Spring Boot/Kotlin web application and a controller that takes a query param. Here's my controller method: import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.ResponseBody import javax.ws.rs.Produces import javax.ws.rs.QueryParam ... @GetMapping("/items") @ResponseBody @Produces(MediaType.APPLICATION_JSON_VALUE) fun getItems(@QueryParam("n") count: Int? = null): Collection<MyItem> { return myItemService.list(count) } The following