Questions tagged [spring-web]

The Spring Web model-view-controller (MVC) framework.

The Spring Web model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale, time zone and theme resolution as well as support for uploading files. The default handler is based on the @Controller and @RequestMapping annotations, offering a wide range of flexible handling methods. With the introduction of Spring 3.0, the @Controller mechanism also allows you to create RESTful Web sites and applications, through the @PathVariable annotation and other features.

Official Documentation

386 questions
6
votes
3 answers

RestTemplate unable to populate object

I have following code to send request and receive a response, it seems like everything is configured but the code is returning NullPointerException. I am not sure whats missing. I printed out readyURL variable which has the correct URL address. The…
Daniel Newtown
  • 2,873
  • 8
  • 30
  • 64
5
votes
2 answers

How to create a non-blocking @RestController webservice in spring?

I'm having a @RestController webservice method that might block the response thread with a long running service call. As follows: @RestController public class MyRestController { //could be another webservice api call, a long running database…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
5
votes
1 answer

Spring WebFlux - Content type 'application/xml' not supported for bodyType=org.springframework.web.multipart.MultipartFile

I am using spring-webflux and want to upload files .... everything works great with just spring-web but when it comes to webflux i have not a clue what's wrong . Be careful in the difference ... i am using :
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93
5
votes
1 answer

CSV on RequestBody using Spring

I need to receive a csv file on the request and process it. @PostMapping(value = "/csv", consumes = "text/csv") public ViewObject postCsv(@RequestBody InputStream request){ // do stuff } But when I execute: curl -X POST -H 'Content-Type:…
kiosia
  • 53
  • 1
  • 8
5
votes
2 answers

Is it possible to activate a spring profile in a WebMvcTest

Given a test class like: @WebMvcTest @RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.profiles.active=test") public class MyControllerTest { ... some tests } I get the error: java.lang.IllegalStateException: Configuration error:…
David
  • 7,652
  • 21
  • 60
  • 98
5
votes
1 answer

Java, groovy REST Clients slower then Postman over 30 times

I wrote REST client using springs RestTemplate in java and in groovy using 'HTTPBuilder'. Both invocation took 10 second on my computer. In Postman and other tools this kind the same post request it took 300 ms. This is simple invocation in groovy…
5
votes
2 answers

How to validate a collection in spring-mvc POST webservice?

I have a simple spring webservice that offers a @PostMapping and takes a json array of elements. I want spring to automatically validate each element in the list. @RestController public class PersonServlet { @PostMapping public void…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
5
votes
1 answer

Loading String[] from properties file into origins field of @CrossOrigin using property placeholder expression

In my spring boot application I have the following controller @RestController(value = "ProjectController") @CrossOrigin(origins = {"${app.api.settings.cross-origin.urls}"}) public class ProjectController { // some request mapping methods } The…
5
votes
2 answers

How to set a context root for all @RestController in Spring Web MVC?

I'm looking to define /api as the root context for all my @RestControllers and don't want to specify it for each of them. For instance, I would like to write @RestController("/clients") instead of @RestController("/api/clients") and make my request…
Anthony O.
  • 22,041
  • 18
  • 107
  • 163
5
votes
1 answer

PUT request: Required request body is missing

Given this Spring Boot application: @SpringBootApplication @RestController public class ShowCase { public static void main(String[] args) { SpringApplication.run(ShowCase.class, args); } @RequestMapping(value = "submit", method…
Roland Weisleder
  • 9,668
  • 7
  • 37
  • 59
5
votes
1 answer

Partial JSON retrieval with RestTemplate

I'm using Spring RestTemplate to send GET request to the third-party service. It returns huge JSON which represents a list of some entities. But every entity is really big and contains tons of unnecessary data. I need to get only three fields from…
Alesto
  • 639
  • 4
  • 13
  • 29
5
votes
3 answers

Backslash (\) in .proprties file is being ignored by Spring's 'Environment' variable

I am trying to load a config.proprties file data in a Spring @Configuration java class using @PropertySource and Environment variable. Example:…
Sanjeev
  • 425
  • 10
  • 17
5
votes
2 answers

Why jQuery rounds value?

Using ajax i request a authenticationID like this: This is wrong because the real HTTP-Transfer is this: (By the way: response-type is "application/json;charset=UTF-8") I see a clash between -1369082024195183657 and -1369082024195183600 How to…
Grim
  • 1,938
  • 10
  • 56
  • 123
5
votes
1 answer

Spring 4 Optional> @RequestParam

Using java.util.Optional as a spring controller request parameter. For simple values (int, String, etc) it works as expected but for a parameter which is of type List or String[] and for which I pass multiple values: …
Bax
  • 4,260
  • 5
  • 43
  • 65
5
votes
3 answers

The value of the HTTP header ' SOAPAction ' was not recognized by the server

When I send a SOAP request to the server it returns following error, though I send similar request using SoapUI and that works. It seems I need to change my SOAP request to the one that I am sending using SoapUI. WSDL is here. [ truncated ]…
Daniel Newtown
  • 2,873
  • 8
  • 30
  • 64