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

Spring REST JSON serialization/deserialization of composite polymorphic types

I use Spring/Spring Boot and Spring MVC with @RestController I have a composite model objects: public abstract class BaseQuery { private final Long characteristicId; ... } public abstract class ComparableQuery extends BaseQuery { …
alexanoid
  • 24,051
  • 54
  • 210
  • 410
4
votes
3 answers

How to send POST request to relative URL with RestTemplate?

How can I send a POST request to the application itself? If I just send a relative post request: java.lang.IllegalArgumentException: URI is not absolute. @RestController public class TestServlet { @RequestMapping("value = "/test", method =…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
4
votes
1 answer

Spring RestController ignore XmlElement annotation in Wrapper Class

I'm using Spring 4.x and I have following RestController method which should return list of all flights @RequestMapping(produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}, method = RequestMethod.GET) public FlightWrapper…
Martin Čuka
  • 16,134
  • 4
  • 23
  • 49
4
votes
1 answer

Unable to download Excel spreadsheet with outputstream data from backend

The REST method to return outputStream data to download an Excel spreadsheet: @RequestMapping(value = "/downloadxls", method = RequestMethod.GET) public @ResponseBody void getRecordsAndExportExcel(@RequestParam("search_param") String students,…
user3428736
  • 864
  • 2
  • 13
  • 33
4
votes
1 answer

Spring Boot running java and web content on different ports in a single application

Is it possible to run static content and java related code on different ports? I have a spring boot project where my java code resides on src/main/java and web content on src/main/resources/static. Is there a possibility to run static content on…
Raki_2012
  • 97
  • 1
  • 7
4
votes
4 answers

How to add csrf token to angular 2 application

I have enabled the CSRF in the java back-end (in SecurityConfig.java file) due to maintain user sessions between the angular2 and spring app. but when the post submission fired, I haven't seen any CSRF token binded to the POST request. How would…
4
votes
2 answers

Spring boot application Post method invocation, 405: Method Not Allowed

I am writing Rest Application with Spring boot. To expose my service code in as REST services. I am able to expose my services in GET method when I am writing Post method with below code of Controller and Pojo class I am getting 405: Method Not…
Gautam
  • 3,707
  • 5
  • 36
  • 57
4
votes
2 answers

Getting "malformed syntax" while hitting REST Controller POST method sending "Request Body"

Here is the Rest Controller Service signature @RequestMapping(value = "/getFilteredReport", method = RequestMethod.POST) public void getFilteredReport(@RequestBody FilteredReportVO filteredReportVO,HttpServletRequest request,HttpServletResponse…
smruti ranjan
  • 741
  • 2
  • 9
  • 23
4
votes
1 answer

Using Spring @RestController with @QuerydslPredicate to handle GET With ZonedDateTime parameters

Im creating an endpoint that will receive dates to do some filtering on the serverside. The code looks like this: @RequestMapping(value = "/invoices", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public…
Leftwing
  • 213
  • 2
  • 8
4
votes
0 answers

how to add custom objectMapper for a specific spring rest controller

I have two controllers in my micro service both are POST and accepts Request body as JSON, one is working fine and another one's JSON input from some othet team and it is with root class name , so I need to write custom object mapper for this later…
nallskarthi
  • 281
  • 1
  • 8
  • 19
4
votes
1 answer

Spring 4.1.5 MVC @RequestParam(required = false, value = "somevalue") fails if a parameter is absent

I have a spring mvc controller which is serving web service requests with multiple request parameters. All the parameters are marked required = false. Still if in the request a parameter is not available, @RequestMapping(value =…
Upen
  • 1,388
  • 1
  • 22
  • 49
4
votes
1 answer

Format LocalDateTime with spring, jackson

In a spring rest application, i send a objet who contain a date { appointmentId: "", appointmentTypeId: "1", appointmentDate: "2015-12-08T08:00:00-05:00" } In my dto side for my appointmentDate i…
robert trudel
  • 5,283
  • 17
  • 72
  • 124
4
votes
1 answer

Ajax request to Spring REST api 415 error

I have a problem with my Spring Rest controller. I am trying to post (PUT) data from my client (angularJS) to my server (Spring), but every time I try to send something I get a 415 Media not supported error. With Maven I have added jackson-core…
Mr.wiseguy
  • 4,092
  • 10
  • 35
  • 67
4
votes
2 answers

Map parameter as GET param in Spring REST controller

How I can pass a Map parameter as a GET param in url to Spring REST controller ?
alexanoid
  • 24,051
  • 54
  • 210
  • 410
4
votes
0 answers

How to add an input stream to a multipart http request? (Java Spring)

I am creating a REST service using Spring 4's rest controller and testing with Spring's RestTemplate. I would like to accept a request to create a new file (POST). The concept of a file in my system contains two parts - (1) Metadata, (2) Content.…
Luke
  • 470
  • 6
  • 10