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
4
votes
2 answers

Multiple query parameter values as comma separated list

Is it possible to build a url with multiple parameter values as a comma separated list? The following snippet prints a url: import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import…
pedromss
  • 2,443
  • 18
  • 24
4
votes
1 answer

Why Unmarshaller behaviour is not consistent?

I have created a simple webservice (spring-web) which is meant to validate the incoming XML with respect to XSD and if any validation errors occured, they should be returned to the requester. The below code does its job... @PostMapping(path =…
Maciej Papież
  • 431
  • 1
  • 6
  • 20
4
votes
3 answers

ConcurrentModificationException with MockRestService when restTemplate used via async executors

Trying to mock out rest responses with spring's MockRestService for integration tests, but AbstractRequestExpectationManager keeps running into ConcurrentModificationException when the actual code uses rest template asynchronously. Test pseudocode…
laur
  • 498
  • 9
  • 17
4
votes
1 answer

Why my request entity InputStream is always empty in ContainerRequestFilter (Spring+Jersey)

I'm totally unable to get the Request payload/form in a JaxRS ContainerRequestFilter. My setup : JDK 8 SpringBoot 1.3.0.RELEASE Jersey 2.22.1 (from SpringBoot) here's my pom : (from Spring Initialzr)
Daniel Marcotte
  • 1,270
  • 3
  • 16
  • 27
3
votes
2 answers

Allow Spring to have multiple WebMvcConfigurer implementations in different jars

When using Spring Web, in this case for rest endpoints & using Spring Boot 2, I can configure interceptors for my app using by implementing the WebMvcConfigurer interface: @Configuration public class SpringWebConfig implements WebMvcConfigurer { …
user1884155
  • 3,616
  • 4
  • 55
  • 108
3
votes
3 answers

Add http headers to RestTemplate by Interceptor or HttpEntity?

If I have some static headers that should be applied to any request sending with RestTemplate: how should those be added? In this example, I'd always want to sent the http header accept=applicaton/json. (it could as well be any other header, also…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
3
votes
1 answer

Test static content with MockMVC in Spring Boot with Slice

I'm trying to figure out a way to test with MockMVC the serving of content using a WebSlice that only autoconfigs org.springframework.web.servlet.resource.ResourceHttpRequestHandler (and not controllers) I've tried something like…
Chris DaMour
  • 3,650
  • 28
  • 37
3
votes
1 answer

Spring Rest template overwriting Authorization header value

I am making rest call like below: REST_TEMPLATE.exchange( external_rest_url, HttpMethod.POST, new HttpEntity<>(dto, getHeaders()), Map.class) and my headers are as below: private HttpHeaders getHeaders() { …
Vinay Prajapati
  • 7,199
  • 9
  • 45
  • 86
3
votes
1 answer

Ignore SSL certificate validation when using Spring RestTemplate

I am using Spring RestTemplate to make HTTPS requests, and I want to ignore SSL certificate Here is my code to create the restTemplate request: TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; SSLContext…
Zak FST
  • 361
  • 3
  • 6
  • 17
3
votes
0 answers

How to stream a resource with Spring WebClient?

I want to connect to an external webserver that offers pdf resources. Those I want to stream directly as a response in my webserver. My goal is to directly stream the resource that I receive. Including all the headers that I receive from the remote…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
3
votes
1 answer

Trying to speed up spring-web endpoint json serialization (afterburner)

I am using Spring Boot 1.5.8 and spring-web 4.3.12. I have noticed that, when I make a request for data from one of our REST endpoints, more time is spent on data serialization than the rest of the operation. I have been looking into strategies to…
Steve Storck
  • 793
  • 6
  • 25
3
votes
1 answer

Spring Boot App fails to register RequestContextListener

I'm creating simple REST controllers, for which in my spring boot app I have added the configuration for RequestContextListener @Configuration @WebListener public class DataApiRequestContextListener extends RequestContextListener { } In the…
Anadi Misra
  • 1,925
  • 4
  • 39
  • 68
3
votes
3 answers

Is there a way to include a spring component in a WebMvcTest

Given production code classes: @RestController @RequiredArgsConstructor public class MyController { private final MyValidator validator; // annotations relating to request mapping excluded for brevity public void test(@Valid…
3
votes
1 answer

Spring: Post request with InputStreamResource

I have some InputStream and want to do post request using RestTempalte from spring-web. public void postRequest(InputStream in){ MultiValueMap parameters = new LinkedMultiValueMap<>(); parameters.add("file", new…
Stanislav Serdiuk
  • 421
  • 1
  • 6
  • 21
3
votes
1 answer

spring REST RequestMethod how to Map a http LOCK and UNLOCK RequestMapping?

seems that this is the same as Custom HTTP Methods in Spring MVC I need to implement a call with http method LOCK and UNLOCK. currently spring's requestMethod only supports public enum RequestMethod { GET, HEAD, POST, PUT, PATCH, DELETE,…