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

Passing String value from Angular $http post to Spring @RestController

I have a REST api endpoint like this - @RequestMapping(value = "/createform/custom/name", method = RequestMethod.POST) public String nameSubmit(@RequestBody String name) { return "you have submitted this name ***** "+name; } From angular…
user6361009
0
votes
1 answer

Controller returns JSON containing two entities instead of one

Here is my controller: // CREATE NEW TODOITEM FROM SENT JSON @PostMapping("/todos") @ResponseStatus(HttpStatus.OK) public ToDoItem newToDo( @RequestBody ToDoItem toDoItem, Principal principal ) { User currentUser =…
doublemc
  • 3,021
  • 5
  • 34
  • 61
0
votes
1 answer

415 Unsupported Media Type with AngularJS and Spring Boot 1.4.3

When I am trying to authenticate an user from AngularJS, I am seeing this warning in Spring Boot log: [WARN ] 2017-02-04 17:09:20.085 [http-nio-8080-exec-1] DefaultHandlerExceptionResolver - Resolved exception caused by Handler execution:…
0
votes
1 answer

JAXB class returned from @RestController XML elements wonky

I am porting an old application that runs on JBoss to Spring Boot/Tomcat and have most everything working except the response XML. The old code appears to be using xmlbeans for the XSD source generation. I've changed this to use JAXB. Here's my…
Bret Hodgson
  • 113
  • 1
  • 7
0
votes
1 answer

Spring GET and PATCH request

I have 2 method in my spring boot REST controller here is my REST CONTROLLER code @RestController public class MainRestController { @RequestMapping(value = "/",method=RequestMethod.POST) public String startMigration(){ return…
atiwari54
  • 51
  • 1
  • 2
  • 7
0
votes
1 answer

Reading properties from Application.properties in Spring Boot REST application

I am trying to access a custom property from application.properties (present in src/main/resources) of my Spring Boot rest application and trying to access that value from my controller Spring boot application class location…
dbas
  • 1
  • 1
  • 5
0
votes
1 answer

Spring Security configuration interceptor URL handle

I have a problem with my Spring Boot application in security configuration. I want to apply basic authentication in a URL. My app's default URL is app/v1/items and my ap'sp secure URL is app/v1/secure/items. With given configuration basic…
0
votes
1 answer

java.lang.ArrayIndexOutOfBoundsException: -64

I am getting this java.lang.ArrayIndexOutOfBoundsException: -64 while calling the spring restfull request from the POSTMAN repeatedly. I am using the GET method on method like this: @RestController public class SchedulerController{ @Autowired …
0
votes
1 answer

Spring REST api returns unknown json format

My API started returning such JSONs: { "links": [ { "rel": "self", "href": "http://127.0.0.1:8888/books/4/instances" } ], "content": [ { "donatorName": "Lee Anderson", "content": [], "links": [ …
EralpB
  • 1,621
  • 4
  • 23
  • 36
0
votes
1 answer

PagingAndSortingRepository pagination information

I've the following class: @RepositoryRestResource(collectionResourceRel = "books", path = "books") public interface BookRepository extends PagingAndSortingRepository { List findByTitle(Pageable pageable, @Param("title") String…
0
votes
1 answer

Why Spring Security doesn't works on this Spring Boot REST API project? It always give me "403 Forbidden" error

I am working on a Spring Boot 1.4.1 application (that implements some REST web services) and I am finding some difficulties trying to implement Spring Security into this project. I have the following situation: 1) I have the CustomUserDetails that…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
0 answers

Spring: Writing controller that reads file uploaded to an endpoint

I am working on a project where the user will upload a file to some endpoint. When the user uplaods the file my controller will parse the contents of this file and do some processing etc. Something like this would happen 1.) User uploads a file to…
varunkr
  • 5,364
  • 11
  • 50
  • 99
0
votes
2 answers

What Http method have I to use to modify this REST resource and what response code have I to return?

I am pretty new in RESTful web services and I have the following doubt. I am working on a Spring MVC application (but this is not so important because my doubt is more related to REST concept). I have this domain class: @Entity @Table(name =…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
1 answer

Spring 4 WebApplicationInitializer not being called

here is my code: public class HelloWorldInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { // TODO Auto-generated method stub …
0
votes
0 answers

able to hit get method endpoint but unable to hit POST method

following is my code @RestController @RequestMapping(value="/users") public class UserController { @Autowired private UserService userService; @RequestMapping(value ="/registration",method = RequestMethod.POST) public void…
Billa
  • 13
  • 1
  • 6