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

Spring Boot default exceptions mapped to standard HTTP status codes

I know it is possible to define custom exception handlers in Spring Boot and have e.g. the IllegalArgumentException exception mapped to the HTTP 400 Bad Request. I am wondering are there any existing exceptions defined in Spring Web/Boot mapped to…
Adam Siemion
  • 15,569
  • 7
  • 58
  • 92
7
votes
1 answer

Spring Boot Mapping Validation Codes to MessageSource Message

Problem: I am trying to use as much Spring Boot Auto-configuration as possible to reduce boiler plate code. I cannot get the Spring Validation codes to automatically map to my externalized messages.properties. It will only work if I add my own…
szxnyc
  • 2,495
  • 5
  • 35
  • 46
6
votes
2 answers

How to validate the size of @RequestParam of type List

I'm creating a Spring-Boot microservice REST API that expects @RequestParam of type List. How can I validate that the list contains a minimum and a maximum amount of values? So far I've tried using @Size(min=1, max=2) which is supposed to…
Nel
  • 169
  • 1
  • 3
  • 9
6
votes
2 answers

Testing @Validated RestController in standalone MockMvc not working

I have RestController annotated with @Validated for validating path variables / request parmas: @RestController @Validated public class MainController implements ApplicationListener { @Autowired private CarsService…
yoka791
  • 576
  • 5
  • 17
6
votes
1 answer

Solve the error java.io.StreamCorruptedException: Inconsistent vector internals

I have a Spring webapp that uses HttpInvoker to connect to a Spring Boot service. I have recently updated the service project to use Java 11 and at the same time updated it to Spring Boot starter 2.1.3.RELEASE. The service project provides an…
Ben
  • 303
  • 1
  • 6
  • 18
6
votes
1 answer

Automatically serialize Rest controllers to CSV instead of JSON in Spring Boot

I am looking for a quick/easy solution how to automatically serialize Rest controllers output to CSV instead of JSON. I have the simplest possible Spring boot application: @SpringBootApplication public class CsvExportApplication { public static…
Adam Siemion
  • 15,569
  • 7
  • 58
  • 92
6
votes
1 answer

How to change ErrorAttributes of ResponseStatusException?

How can I change the error attributes that are exposed when throwing a ResponseStatusException? Especially I want to hide the exception, error and status type in the json, but only during production. @RestController public class…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
6
votes
1 answer

Spring WebClient put Mapping: Content type 'application/json' not supported

I am trying to use WebClient to call by REST another service, but I always get error: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/json' not supported All allocations have same version of…
Beri
  • 11,470
  • 4
  • 35
  • 57
6
votes
1 answer

How to accept text/csv as content-type in spring-web servlet?

I want to create a simple webservice that produces text/csv content. But I cannot request it: @RestController public class MyServlet { @PostMapping(produces = {"text/csv", "application/json"}) public Object post() { //... …
membersound
  • 81,582
  • 193
  • 585
  • 1,120
6
votes
1 answer

Spring Boot WebFlux NettyServerCustomizer does not work

I have very simple application, I read I can use NettyServerCustomizer to customize NettyServer. But it does not work, implementation of the NettyServerCustomizer interface is not being called. Project is generated by Spring Initializr Code of…
Simon
  • 997
  • 1
  • 15
  • 29
6
votes
0 answers

Spring Boot 2 - EmbeddedServletContainerFactory not found

My Spring Boot 2 web application is working fine but now I want to redirect all http requests to https. However EmbeddedServletContainerFactory and TomcatEmbeddedServletContainerFactory can not be imported. It says that…
Vmxes
  • 2,329
  • 2
  • 19
  • 34
6
votes
0 answers

What is the use of outputStreaming in SimpleClientHttpRequestFactory?

I am using OAuth2RestTemplate class of spring-security-oauth2-2.1.1.RELEASE for rest client services. Ideally, whenever an access token expires, the template should retry the failed request by fetching the new access token. But at times, when an…
6
votes
0 answers

Use @Transactional on Spring Rest CompletableFuture result

In my current web application, i use @RestController with CompletableFuture result for all services. Database operations are asynchronous (CompletableFuture methods), but i would like commit operations only before send result i would like to commit…
Fabien
  • 95
  • 1
  • 5
6
votes
1 answer

How can I use multiple Oauth2 SSO Servers on a single Spring boot application with Spring Cloud Security Oauth2?

I'd like to give users the option to login to a Spring Boot web application using their Google or Facebook account. I checked The Spring Cloud Security documentation and also This GitHub issue to add such SSO functionality, but on both they only…
Raul G
  • 473
  • 1
  • 6
  • 18
6
votes
1 answer

Spring Session Redis and Spring Security how to update user session?

I am building a spring REST web application using spring boot, spring secuirity, and spring session (redis). I am building a cloud application following the gateway pattern using spring cloud and zuul proxy. Within this pattern I am using spring…
1 2
3
25 26