Spring MVC bind on a typed field

I have a Spring MVC controller like this: @RequestMapping(value = "/search", method = RequestMethod.GET) @ResponseBody public Object grid(Search<MyFilter> search){ ... } My Search object is like: public class Search<...
more »

2017-01-12 17:01 (2) Answers

Spring and Jackson: set json ignore dynamically

I have some JPA models: "Category" and "Article": @Entity @Table(name = "categories") public class Category { private int id; private String caption; private Category parent; private List<Category> childrenList; @Id @GeneratedValue(strategy =...
more »

2017-01-04 22:01 (2) Answers

Spring boot mvc async execution

I'm trying to execute simplest async REST controller using java.util.concurrent.Callable: @RequestMapping("/AsyncRequest") public Callable asyncRequest() { return () -> { Thread.sleep(3000); return "reply"; }; } Then I r...
more »

2016-12-27 20:12 (1) Answers

Serialize model without relation

I have two models: @Entity class ModelA { ... @OneToMany(mappedBy = "modelA") @JsonManagedReference private List<ModelB> modelBs = new ArrayList<ModelB>(); ... } @Entity class ModelB { ... @ManyToOne @JoinColumn(name =...
more »

2016-12-24 00:12 (1) Answers

What's JSON prefix used for?

I know it is a stupid question but I did not find expected answer by Google. One of new feature of Spring MVC 4.3 is supporting to configure JSON prefix <mvc:message-converters> <bean class="org.springframework.http.converter.json.Mappi...
more »

2016-12-11 03:12 (1) Answers

Spring, REST, Jackson and cyclic hierarchy

Suppose I have the following entity hierarchy class Parent { Long id; List<Child> children; } and class Child { Long id; Parent parent; } I want to be able to make two types of REST request: /parents/1 that should return: { "i...
more »

2016-11-13 23:11 (0) Answers

Java Spring Interceptor with no XML

I understand that it is possible to configure a Spring application without the use of XML config files, and have commited to this method. I am not sure, however, how to declare HTTP interceptors in this manner. I am using this tutorial, which decla...
more »

2016-11-07 20:11 (2) Answers

Spring MVC - Jackson XML format

I would like my controller to return the following XML: <?xml version="1.0"?> <ResponseDTO result=”OK” timestamp=”20110322T152403Z"> <myId>9999.99</myId> <currency>USD</currency> </ResponseDTO > B...
more »

2016-11-06 14:11 (1) Answers