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

Not able to consume the Spring MVC Rest service from stand alone html file

I have created the REST Service using Spring MVC (@RestController ) which is used to consume Json request and expose the Json response and I placed the .html file inside the web-app folder . in that html file using jquery+Ajax i am able consuming…
0
votes
0 answers

RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type

I am trying to access a third party API, via a RestTemplate but I have been having difficulty for days ... @Controller public class ListUsersController { @RequestMapping("/listUsers") public ModelAndView listUsers() { …
0
votes
2 answers

Error Unit Testing of Spring MVC Controllers calling REST API

I am unit testing the spring MVC controller in my small app, but getting the following error: INFO: **Initializing Spring FrameworkServlet ''** Oct 30, 2015 5:37:38 PM org.springframework.test.web.servlet.TestDispatcherServlet initServletBean INFO:…
0
votes
1 answer

Spring not allowing RequestMethod.DELETE

I have this endpoint that invoke my service method which in turn call my repo class to Delete a user, but when i call this endpoint through postman i get a request Method not supported" printed in the console,any help would be greatly appreciated…
0
votes
0 answers

NullPointerException when using PersistentEntityResourceAssembler.getResource on existing Obj instance

I'm trying to build a restful controller with HAL links and custom methods. When I'm using a getResources from PersistentEntityResourceAssembler (HAL links) and this cause NullPointer. StackTrace java.lang.NullPointerException: null at…
0
votes
0 answers

HandlerInterceptorAdapter - Set Request Header

I want to override one of the HTTP Headers as soon as I get the request from the consumer. I have a class that extends HandlerInterceptorAdapter where I intercept the HTTP request. Is there a way to override the one of the header values inside the…
Punter Vicky
  • 15,954
  • 56
  • 188
  • 315
0
votes
4 answers

@RequestBody not working - HTTP Status 415

I have a problem. I try so send http post to my controller with angularjs. @RequestMapping(value = "/books/manage", method = RequestMethod.POST) @ResponseBody public void manageBooks(@RequestBody final BooksDTO dto) throws SystemException,…
jahra
  • 1,173
  • 1
  • 16
  • 41
0
votes
0 answers

Client to server date not correct

I use spring rest and jackson 2.6.1 I have a url like So from the client this url (with startDate=13/10/2015) /rest/appointments? @RequestMapping(value = "/appointments", method = RequestMethod.GET) public List
robert trudel
  • 5,283
  • 17
  • 72
  • 124
0
votes
2 answers

Spring boot query parameters map bind to different types

I have a rest call that takes in arbitrary query parameters. To capture these I am using @RequestParam Map queryParams. I want each entry in the map to be bound to different type e.g. some to date, some to doubles, some to string, etc... How can I…
user2279337
  • 691
  • 5
  • 13
  • 26
0
votes
1 answer

Unauthorized access with spring security

I try to add security to a rest application. I followed this tutorial: http://www.codesandnotes.be/2014/10/31/restful-authentication-using-spring-security-on-spring-boot-and-jquery-as-a-web-client/ I configured my class who extends…
0
votes
2 answers

Similar fields in DTO

I want to create a DTO. The DTO will be used to map HTTP request to a REST webservice in spring. My controller looks like this: RequestMapping( value = DmsRestSvcApi.DOCUMENT_SEARCH_PATH, method = RequestMethod.POST, produces = {…
0
votes
0 answers

org.codehaus.jackson.map.JsonMappingException: failed to lazily initialize a collection of role: entity.Foo.bars

I have an Entity @Entity @JsonAutoDetect public class Foo implements Serializable { @Id @GeneratedValue private Integer id; private String title; @ManyToMany(cascade = {CascadeType.MERGE}) @JoinTable(name = "foos_bars", …
Logical Error
  • 207
  • 1
  • 2
  • 14
0
votes
2 answers

Spring 4.2.1 RestController tried to return template instead return JSON

I tried to create a Spring Rest Controller, based on this example i create a controller like this. DeveloperRestController.java @RestController public class DeveloperRestController { @RequestMapping("/developer/list") public Developer…
zho
  • 643
  • 1
  • 12
  • 27
0
votes
2 answers

Spring Restful service URL encoding issue with "."

@RequestMapping(value = "/newLoadtest/{loadtest}", method = RequestMethod.POST) public @ResponseBody void addNewLoadTest(@PathVariable("loadtest") String loadtest) { System.out.println(loadtest); } This is the code that I have written and…
user3100209
  • 357
  • 1
  • 4
  • 17
0
votes
1 answer

spring controller could not recognize

I tried following code to run sample spring rest application with tomcat7. It works properly, but it could not recognize HelloController. Debugger could not able to reach hellocontroller. http://localhost:8080/Sample/welcome throws 404…
RohanB
  • 294
  • 2
  • 5
  • 19
1 2 3
99
100