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

389 questions
4
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
  • 43
  • 6
4
votes
1 answer

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…
Yosi Karl
  • 377
  • 1
  • 12
4
votes
1 answer

Spring boot 2: Plus (+) sign is not getting encoded in query param

Currently I am migrating one of my micro service to spring boot 2 from spring boot 1.x. consider there are two services A and B. Service A calls the rest end point of service B. In query Param service A is passing an alphanumeric string which also…
Sachin
  • 431
  • 3
  • 11
4
votes
2 answers

Multiple asynchronous HTTP requests using Resttemplate

I have a service which uses springs RestTemplate to call out to multiple urls. To improve performance I'd like to perform these requests in parallel. Two options available to me are: java 8 parallel streams leveraging the fork-join common pool…
Sam
  • 691
  • 2
  • 7
  • 15
4
votes
2 answers

How to configure direct field access on @Valid in Spring?

How can I tell spring-web to validate my dto without having to use getter/setter? @PostMapping(path = "/test") public void test(@Valid @RequestBody WebDTO dto) { } public class WebDTO { @Valid //triggers nested validation private…
membersound
  • 66,525
  • 139
  • 452
  • 886
4
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
  • 14,533
  • 4
  • 47
  • 84
4
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
  • 66,525
  • 139
  • 452
  • 886
4
votes
3 answers

Spring-Boot Embedded Tomcat - generate localhost.log and cataline.out files

I have a spring-boot application running with an embedded tomcat. We are using logback and slf4j for logging. I am trying to figure ways to generate catalina.out and localhost.log files through spring-boot application. It looks like catalina.out is…
jagamot
  • 4,938
  • 12
  • 55
  • 96
4
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…
4
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
  • 66,525
  • 139
  • 452
  • 886
4
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,235
  • 5
  • 30
  • 44
4
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…
4
votes
0 answers

Custom Login Page with Spring Boot and Vue.js

I want to use my custom loginpage, made with Bootstrap-Vue and the Vue.js, with my spring boot backend. I'm using Spring Security. This is my custom login form
C. Oltan
  • 111
  • 1
  • 1
  • 4
4
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
  • 7,475
  • 5
  • 29
  • 52
4
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
  • 375
  • 6
  • 17