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
12
votes
3 answers

package org.springframework.web.bind.annotation does not exist even though it's defined in POM

So I have this code import org.springframework.web.bind.annotation.GetMapping; And I already have the following in my POM file war 4.3.0.RELEASE
MassiveParty24
  • 121
  • 1
  • 1
  • 3
11
votes
1 answer

Async Spring Controllers vs normal Controllers

I wanted to analyze the improvement I may see by enabling Async Controllers in Spring Boot over normal controller So here is my test code. One API returns a Callable and another is normal controller API. Both APIs block for 10secs simulating a long…
hellojava
  • 4,276
  • 9
  • 25
  • 37
10
votes
3 answers

Spring form submission with minum boilerplate

I've been trying to figure out what the best practice is for form submission with spring and what the minimum boilerplate is to achieve that. I think of the following as best practise traits Validation enabled and form values preserved on…
Johan Sjöberg
  • 43,692
  • 19
  • 120
  • 139
10
votes
2 answers

Null @AuthenticationPrincipal with Spring-Boot / Security

I setup my Spring Security application according to the reference document and after hours of troubleshooting I continue to get a null @AuthenticationPrincipal passed into my controller. The authentication mechanism is working fine against the…
szxnyc
  • 2,235
  • 5
  • 30
  • 44
10
votes
3 answers

How to map JSON fields to custom object properties?

I have a simple json message with some fields, and want to map it to a java object using spring-web. Problem: my target classes fields are named differently than int he json response. How can I anyhow map them to the object without having to rename…
membersound
  • 66,525
  • 139
  • 452
  • 886
9
votes
4 answers

Content type 'text/plain;charset=UTF-8' not supported error in spring boot inside RestController class

I got the following @RestController inside a spring boot application : @Data @RestController public class Hello { @Autowired private ResturantExpensesRepo repo; @RequestMapping(value = "/expenses/restaurants",method =…
nadavgam
  • 1,452
  • 3
  • 15
  • 31
8
votes
1 answer

SmartValidator - manually calling validate with groups

Spring 4.3.2 I need to call SmartValidator.validate() manually and I need it utilize the validation groups that I have defined on the target entity. The javadoc says this... "This variant of validate() supports validation hints, such as …
Jim Ott
  • 625
  • 6
  • 21
8
votes
2 answers

Spring Web MVC: no request body possible for HTTP DELETE anymore

I have a question for the developers of Spring Web MVC. In a nutshell: previously it was possible to send a request body in an HTTP DELETE message, but now it is not possible anymore. Why? In detail: We are using…
Johannes Flügel
  • 2,442
  • 3
  • 13
  • 29
8
votes
4 answers

Download or redirect with error message to another controller action in Spring web MVC

Idea: I have a Spring web MVC action that should accomplish one or both of these taks: Download a file from a remote server and write the input stream to the response output stream Or catch the exception of the download, set one of multiple error…
swaechter
  • 1,173
  • 3
  • 20
  • 41
8
votes
2 answers

Spring CORS controller annotation not working

I want to allow cross origin requests for one domain. My project uses Spring so I want to take advantage of the new CORS support. I am using version 4.2.0 for all springframework dependencies. I followed the example here…
ilinca
  • 1,293
  • 15
  • 17
7
votes
1 answer

Converting Lazy Loaded object to JSON in spring boot jpa

I am getting error while sending the Lazy loaded object as a JSON in response to REST request in spring boot. When I request from browser to fetch the parentTree and call get method to get the version to test the lazy loading and return version but…
Developer
  • 323
  • 4
  • 15
7
votes
1 answer

Spring Rest Controller: how to selectively switch off validation

In my controller I have a method for creating an entity import javax.validation.Valid; ... @RestController public class Controller { @RequestMapping(method = RequestMethod.POST) public ResponseEntity create(@Valid @RequestBody RequestDTO…
Johannes Flügel
  • 2,442
  • 3
  • 13
  • 29
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…
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,693
  • 8
  • 25
  • 60
5
votes
3 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
  • 141
  • 1
  • 8
1
2
3
25 26