I would like to know how to format the date time correctly? The result is Localdatetime yyyy-MM-ddTHH:mm. Could you advise how to solve? I’m using Java 11, and does it because @JsonFormat not support @RequestParam? Controller: Entity: Answer Since you are using Spring-boot , I’m also assuming you …
Tag: spring-boot
Spring SPEL collection projection
A simple question on SPEL collection selection. Look at section 10.5.17 Collection Selection on this page https://docs.spring.io/spring/docs/4.3.10.RELEASE/spring-framework-reference/html/expressions.html What i need is the selection ‘Serbian’ to come from outside and not be a fixed hard coded Str…
No mapping for request with mockmvc
Currently struggling with problem when I get ‘mapping error for request’ with following controller/test configuration. Controller: Test: Configuration: After test execution I get No mapping for POST /subscriber/session The reason for the struggle is that my code from other modules with the same co…
OffsetDateTime always converted to UTC
I’m having a very simple spring boot app that gets and returns a timestamp. The code is as follow: Controller Model I’ve noticed that when I’m sending timezones which are not UTC the object I’m receiving converted into UTC – for example, the following call: has this response: Is …
Which HTTP status code is correct for Subscription cancel exception?
Which HTTP status code is correct for Subscription Canceled exception? I need to throw an exception when the user tries to accesses a certain page. I checked a few statuses like Payment Required, but it’s not satisfying the requirement. Any suggestion? Answer Which HTTP status code is correct for Subscr…
Repeatedly filter a response using Spring WebClient
I’m new to Spring and even newer to WebClient. I want to filter the body of a Get response repeatedly with one second intervals for 2 minute duration using Springs’ WebClient. I’m performing a get request which returns an empty JSON list of strings. At some moment of time the body is going t…
How to add rewrite rule to spring boot 2.3.1
I have a Spring Boot application based on this example. Now the question is how can I add rewrite rules to my application that add /index.html when user visit the root URL. I mean when user visit http://localhost:8080/my-app or http://localhost:8080/my-app/ then I redirect him or her to http://localhost:8080/…
WebClient – adding defaultHeaders
I’m trying to put multiple headers into defaultHeaders(), But I don’t have idea how to create Consumer object from return of createHeaders() method I can build my header in that way: but how to wrap it into Consumer? Answer Clearly the method doc says that it needs a Consumer of some Type. So you …
Why is @Validated required for validating Spring controller request parameters?
With the following validation setup in an annotated MVC controller: @Validated on the controller is required for the method parameter since it’s not a “complex” object. In comparison, the @Valid annotation on the setOther method works without the @Validated annotation. Why is @Validated requ…
Passing List in @RequestHeader Restapi
I want to pass list of string in my controller via Request Header @RequestHeader(“list”) final List<String> listOfString. Can this be used. How can I pass list of string in header via Postman? list={item1,item2,item3}. This is not working while I want to test via Postman. Is there any way? A…