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
0
votes
1 answer

Restrict access to REST webservice

I have a Spring Rest webservice which I call from my website (html pages), So anyone can retrieve the webservice URL from source code of a html pages. Both webservice and website are deployed in the same server (id address: X.Y.Z.T) My object is to…
0
votes
2 answers

How to add HttpServletRequest param to complex RestController bean?

I have a complex bean holding the rest parameters, eg: public class MyRestParams { private HttpServletRequest req; private @NotBlank String name; //getter, setter } Usage: @RestController @RequestMapping("/xml") public class MyServlet…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
0
votes
1 answer

Issue with Spring mvc REST and mongoDB date field

I am having trouble with returning date stored in mongodb in the REST JSON response. I am using Spring-MVC 4.2.5 @RestController and @ResponseBody. I have date stored in Mongodb as "createdDate" : ISODate("2016-04-14T20:26:00.682Z"). when I return…
manish arora
  • 1,991
  • 1
  • 9
  • 5
0
votes
2 answers

Spring Hateoas Deserialize Links in Payload to actual Entities

I have some controller method like: @RequestMapping(value = "/person", method = RequestMethod.POST) public ResponseEntity create(@RequestBody Person person) { personRepository.save(person); return new ResponseEntity<>(HttpStatus.OK); } The…
Benny
  • 1,435
  • 1
  • 15
  • 33
0
votes
1 answer

Sendind files to web servicce : HTTP Error 415 Unsupported media type

I try from my rest client to send files to my web service but i keep getting 415 when i'm sure of the media type i'm sending. I'm using spring MVC : Here code of the rest client : public Response uploadFile(FormDataMultiPart multipart, ...) { …
0
votes
1 answer

How to port SpringMVC Application to SpringREST?

We have created SpringMVC application using Spring-Boot and Thymleaf. Now as per new requirement, I have to convert them to SPring-REST for external application consumption(AngularJS and Android App) without affecting the thymleaf pages. Please…
0
votes
1 answer

Adding @ModelAttribute results in 400 (Bad Request) in Delete Request

I can submit a delete request fine with the following: @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public ResponseEntity deleteTest(@PathVariable String id) { return new ResponseEntity<>(Result.Success("Hi " + id +…
Zack Macomber
  • 6,682
  • 14
  • 57
  • 104
0
votes
2 answers

only space in URL of a GET request in Rest causes 404

Team, I have created a search API and made it as GET request. Now when I try to give only a single space in search, it gives me 404 resource not found error. For example: http://localhost:8080/myproject/myapp/search/ ?pageNo=1&limit=20 As you can…
Zeeshan
  • 177
  • 1
  • 15
0
votes
0 answers

Custom JSON serialization in Spring

I have three entities: @Entity class Group { @id Long id; String name; String faculty; @OneToMany(mappedBy = "group", fetch = FetchType.LAZY, cascade = CascadeType.ALL ) List scedule; ... } @Entity class Schedule…
0
votes
1 answer

Spring data repository and rest controller: end point mixing & overriding

It is fairly common to expose the following endpoints for REST resources @GET customers/ ==> list of customers @POST customers/ ==> add a customer @Get customers/:id ==> specific info of customer @PUT customers/:id ==> override a customer @PATCH…
0
votes
1 answer

Spring Rest Implementation with CORS Support - Issue with multiple requests (Response to preflight request doesn't pass access control check)

I am facing issues with the CORS support for Spring Rest Implementation. Strange thing here is, I can login successfully with Rest API but after login, getting exception as- Response to preflight request doesn't pass access control check: No…
0
votes
2 answers

How to parse a Json array with values "id": 1.1.1.1

I have a $http get method which should invoke my local server. I am getting proper response from my server through postman. Following is my Json…
0
votes
1 answer

how to load json data returned via ajax call in custom modal dialog

I'm newbie and wanna favor that is I have a link to open a custom modal dialog( not a bootstrap modal) as following
Arshad Ali
  • 3,082
  • 12
  • 56
  • 99
0
votes
5 answers

Spring @ResponseBody JSON

I have a Spring 3 controller that returns a JSON object. I am using @ResponseBody annotation, and jackson-mapper-asl jar, with which the Spring will handle the JSON conversion automatically. The 3 return statements returns different JSON format. Can…
0
votes
3 answers

Add Access-Control-Allow-Origin to Web Service

I have a webservice like: @Controller @RequestMapping("/") public class ApplicationController { @RequestMapping(value="/Changes", method = RequestMethod.GET) public String inspect(ModelMap model) { model.addAttribute("msg",…
PRVS
  • 1,612
  • 4
  • 38
  • 75