Questions tagged [get-mapping]

67 questions
1
vote
1 answer

GetMapping "produces" works even though doesn't match accept header

Intro There is a @GetMapping attribute, as the following in one of our projects: @GetMapping(path = "/", produces = SaConstants.SA_MEDIA_TYPE) public HttpEntity> get(HttpServletResponse response) { In the SaConstants class: public…
Menelaos
  • 23,508
  • 18
  • 90
  • 155
0
votes
4 answers

SpringBoot Return String as JSON

I have a method that returns a fully formatted JSON as a String, ex { type: "", List1: []...} I'm trying to return that in a way that the browser interprets it as a JSON (Firefox). I've tried specifying that it produces="text/plain" but no luck. I…
Luke Jones
  • 11
  • 1
0
votes
2 answers

Why is the RequestMapper not displaying on Webpage?

I am trying to use a RequestMapper and GetMapper to display a Java list using Spring Boot. @RestController @RequestMapping(path = "api/v1/student") public class StudentController { @GetMapping() List getStudents() { return…
0
votes
2 answers

How return html page in Spring Boot without thymeleaf

If i delete from pom.xml spring-boot-starter-thymeleaf then my @GetMapping cant return html page. [enter image description here](https://i.stack.imgur.com/NJvOn.png) I tried: add @ResponseBody - not working (his return string in web site, not html…
Igor Makarov
  • 1
  • 2
  • 1
0
votes
2 answers

404 path not found error in my controller class

I am trying to create a task manager using Spring Boot and this is my Taskmanager controller class I am getting 404 path not found error while calling /addTask and my /tasks is working properly. package com.firstapp.taskManager.controller; import…
0
votes
3 answers

How to handle a @RequestParam not defined

So, as the title says i have this piece of code here @GetMapping("/concat") public String conc(@RequestParam("c1") String con1,@RequestParam("c2") String con2){ return stringService.conc(con1, con2); } which just return a string concatenated …
CookieXIV
  • 3
  • 1
0
votes
0 answers

Unable to get mapping to work in springboot

I have tried everything and I am unable to get springboot to map anything using @getmapping. I have previously done this in another springboot application with no issue so I confused as why I am having issues. Here is my code for the main…
0
votes
1 answer

Front slash(/) and special characters in rest url

Restful web services : GetMapping url has a variable which should be passed as a path variable but that variable contains front slash and special characters in it. Any suggestions on how to handle that in springboot. @GetMapping(value =…
user20824479
0
votes
0 answers

.findAllbyid(name) to filter data +kotlin+android

im trying to make search fun using getmapping and .findallnbyid(name) i cannot pass name here is my code: @GetMapping("/student/find{name}") fun SearchData(@PathVariable("name") name: String): ResponseEntity> { val…
jac
  • 11
  • 1
0
votes
0 answers

Java - Spring MVC - Redirect to route without button/change url dynamically

Please excuse me for my bad english. This is my problem using Spring MVC: Let assume that a user is clicking on a button and arrived to a route called "/randomRoute". I want him to have the possibility to keep doing his job (for example filling a…
0
votes
2 answers

How to filter based on something other than ID

I am trying to build a very small REST API with a mysql database. I am using Spring boot and Tomcat to deploy it locally. One of the services I am working on is to retrieve messages from the database. I have the ability to get ALL the messages…
google
  • 13
  • 3
0
votes
1 answer

Spring boot. Map request to object if field isnt there

Suppose I make a get request to foo() with the JSON body: { „a“: „hallo“, „b“: „world“, „aa“: 10 } @PostMapping("/foo") public void foo(@RequestBody MyClass myClass) { //do stuff } class MyClass { String a; …
EraZer
  • 75
  • 6
0
votes
1 answer

Error 404 requestmapping and getmapping url doesn't work

Hi I m beginner and I have a simple problem, my url doesn't work. localhost:8080 work but not with /api. The project is built properly. Localhost:8080 I put @ComponentScan("com.tutojwt.test.repository") because without it doesn't work. Here my…
ben171
  • 1
  • 1
0
votes
2 answers

GetMapping with JSON array parameter

I am using a FeignClient and a GetMapping to interact with an external system. My GetMapping is defined as: @GetMapping(value = "/path/to/endpoint?fields=[\"nm\",\"label\"]") public String hitEndpoint() {} Debug shows that the endpoint is…
bkqdad
  • 15
  • 3
0
votes
2 answers

Rest Controller works just for Application class

I'm trying to do a getmapping method using rest-api which will return as a JSON on localhost: 8080. When I do this from the default Application class it works great but when I move this functionality to another class nothing happens. Could someone…