Questions tagged [spring-restcontroller]

@RestController is Spring MVC's shortcut annotation for creating Rest Controllers. Use this tag for questions relating to the use of this annotation.

@RestController is an Spring annotation that is used to declare controllers where all @RequestMapping annotated methods assume @ResponseBody semantics by default.

Useful links:

1579 questions
3
votes
1 answer

SpringBoot @RestController not accessible from outside docker container

tl;dr One RestController answers properly, the other doesn't, if run inside a Docker container. The service has two APIs alive @CrossOrigin(origins = "*", maxAge = 3600) @RestController public class AliveController { @RequestMapping(value =…
michaelbahr
  • 4,837
  • 2
  • 39
  • 75
3
votes
2 answers

Did not find handler method

I am trying to invoke a rest endpoint, but getting this info when I call it, resulting in a 404 error in UI 2016-08-07 13:43:42.611 DEBUG 27834 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path…
sromit
  • 900
  • 3
  • 16
  • 43
3
votes
2 answers

Spring rest controller's " MultipartFile[] multipartFiles" always recieves [ ] or null files

I am using Spring 4 with Java Config. I want multiple files to be uploaded to the server but problem is my MultipartFile[ ] parameter will always receive empty/[ ] parameter. Let me share my code here is my 'AppConfig' @Bean(name =…
Haseeb Wali
  • 1,181
  • 3
  • 14
  • 34
3
votes
3 answers

Validation in @RepositoryRestController

I'd like to validate my DTO in my @RepositoryRestController with the javax annotation @Valid. However @RepositoryRestController doesn't currently support @Valid as you can see in this ticket: https://jira.spring.io/browse/DATAREST-593 If I use a…
3
votes
2 answers

Spring rest controller and paging

I use spring 4.2 and rest and I would like to use paging. What is the way to use paging with spring rest controller? @RequestMapping(value = "/members/{memberId}/payments", method = RequestMethod.GET) public Page
robert gagnon
  • 311
  • 1
  • 5
  • 14
3
votes
1 answer

Spring @RestController cannot return unicode

I have a simple RestController which returns a unicode string: @RestController @RequestMapping(path = "/") public class FooController { @RequestMapping(method = RequestMethod.GET) public String test() throws Exception { return "ỗ ẵ ẫ…
yelliver
  • 5,648
  • 5
  • 34
  • 65
3
votes
3 answers

Rest service with oauth2: Failed to find access token for token

I try to create spring rest service, whis is autenticated by my own oauth2 resources server. I created resource server: @Configuration @EnableResourceServer protected static class ResourceServer extends ResourceServerConfigurerAdapter { …
3
votes
0 answers

AngularJS Spring Rest MissingServletRequestPartException Required request part 'file' is not present

I'm trying to upload a file from UI and getting the below exception: error":"Bad Request","exception":"org.springframework.web.multipart.support.MissingServletRequestPartException","message":"Required request part 'file' is not present." Javascript…
3
votes
0 answers

Downloading files with swagger-ui

I have a scala controller which puts in response's outputstream a zip file. If I use direct link, file is downloaded without problems. But when I execute request through swagger-ui, file binary content is shown on UI and loading doesn't…
funny-shmunny
  • 87
  • 1
  • 13
3
votes
1 answer

Using exception for communication

I have heard that one should not use exception for communication. I have a scenario that I would like to discuss. We have a rest controller that invokes a service that is responsible for fetching a product from the database. Currently if product…
user2975699
  • 585
  • 1
  • 9
  • 22
3
votes
2 answers

Spring Resttemplate postforobject returns null as object response if used with ClientHttpRequestInterceptor

I am trying to consume a rest service and i am posting some data, with Spring RestTemplate postForObjectMethod but i am getting a null response, even though i can see the request and response in payload. [Update] I am using an interceptor…
user1697113
  • 683
  • 2
  • 14
  • 24
3
votes
4 answers

how to return a response body when header is missing in spring REST api

I am passing a header to a spring REST api like: @RequestHeader(value="test-header") header is mandatory here for the API, so I do not want to keep it optional. when no header is passed, any call to the API returns a standard 400 error indicating…
user1892775
  • 2,001
  • 6
  • 37
  • 58
3
votes
1 answer

Send Large Files like ISO via Java REST

I creating a REST service which will send large Files such as ISO image,but currently I am getting out of memory error,Below is my code @RequestMapping(value = URIConstansts.GET_FILE, produces = { "application/json" }, method =…
arpit joshi
  • 1,987
  • 8
  • 36
  • 62
3
votes
0 answers

what is the best way to create chat api(rest webservices) using spring

i want to create a chat api(rest webservices) with spring . the api needs to support for all mobile platforms (ios, andriod , ... etc). can any one please suggest what is best way to build this in java.
3
votes
3 answers

Unable to get different Content-Types in request mapping using Spring Framework

Here is my controller class: @Controller @RequestMapping("/actuator") public class HealthController { @RequestMapping(value = "/metrics", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON) @ResponseBody public…
brain storm
  • 30,124
  • 69
  • 225
  • 393