Questions tagged [get-mapping]
67 questions
3
votes
1 answer
How can I target the root path in Spring controller?
I am trying to add a default path in my Spring controller.
For example: I would like http://localhost:8080 to render the same view as http://localhost:8080/index
I tried that:
@Controller
@RequestMapping("/")
public class RecipeController {
…

Malouette
- 33
- 5
3
votes
2 answers
field missing in the json response spring boot
I have Stock response class with only two fields as follows
class StockResponse {
private String orderId;
private String status;
//constructor
//getters and setters
}
and the also the controller as follows
@RestController
…

Odwori
- 1,460
- 13
- 14
2
votes
0 answers
Spring @GetMapping annotation does not work
I have href in index.html which should redirect to showNewBook and then it should redirect to new_book.index but when I click on the link there is an error which says "Whitelabel Error Page,
This application has no explicit mapping for /error, so…

Ivana
- 35
- 3
2
votes
1 answer
Conditional @JsonView within controller method
I have a controller method annotated with @JsonView. The current requirement is to have this same method return the response using a different JsonView if the userId given in parameter matches the authenticated user. How to achieve this knowing that…

khazouss
- 55
- 8
2
votes
1 answer
Adding encoding to @GetMapping
I want to add encoding to the response for the mapping controller. But for some reason a compilation error. Only requires an array of values
How do I add encoding to the response?

mfufb
- 79
- 5
2
votes
1 answer
How can I use ID(arguments) to different GetMappings
When I try localhost:8080/api/employees I get a list (JSON-format). I would also like to get a single employee by ID. When I try localhost:8080/api/123abc I cannot find the employee with that ID. My response is:
Whitelabel Error Page
This…

Magnus Strand
- 113
- 6
2
votes
2 answers
Spring Boot @GetMapping rule for multiple mapping
I have 3 different method in controller for get requests.
-the 1st one to get a user by id with a path variable:
@GetMapping(path="/{id}")
public ResponseEntity getUserById(@PathVariable Long id)
The 2nd gets a user based on the…

Manta
- 490
- 5
- 18
2
votes
1 answer
How to support wrapping variable in braces with Spring GetMapping annotation
I need to support wrapping a list of ids in curly braces with Spring GetMapping annotation.
When I use square brackets like this, it works:
@GetMapping("/get/[{ids}]")
but double the braces and everything blows up
@GetMapping("/get/{{ids}}")
with…

Schenz
- 1,113
- 8
- 14
1
vote
1 answer
PostAuthorize not working on method called from request handler
I thought PostAuthorize decorated method should return an object having an attribute that is a part of authorization(e.g, 'username'). I put the annotation on getOrder() method show below. Why the annotation is not…

Park JongBum
- 1,245
- 1
- 16
- 27
1
vote
3 answers
@Query with 2 parameters in Java Spring
I'm looking for a solution for following problem -
i want to create a @Query like this:
@Query("select s from Student s where s.name like %?1% and s.surname like %?1%")
because I need to be able to show student with given name and surname. I was…

Bajter
- 7
- 3
1
vote
1 answer
spring boot mapping without slash
I'm having a controller mapping as shown below
@RestController
@RequestMapping("/v1/connector")
public class Controller
and the API mapping as below
@GetMapping("2/auth")
when I hit the URL it's giving me the response as request URL not found.
Can…

rajesh shukla
- 11
- 3
1
vote
0 answers
I keep getting this IOException error message "Can't reset method: already connected", on my spring boot program
@GetMapping("/check")
public String checkURL(@RequestParam String url) {
String returnMessage = "";
try {
URL urlObj = new URL(url);
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();
…

Ricky Patel
- 21
- 3
1
vote
1 answer
Spring Boot consuming webservice with scheduler
Hello I have RestController anotated class with a method like this:
@Bean
@GetMapping
@Scope("prototype")
public Info[] setInfo()
{
return m_restTemplate.getForObject(m_url, Info[].class);
}
Here I can get info[] and I use it in my SQL…

iraquois
- 37
- 8
1
vote
2 answers
Springboot @GetMapping method injection with object as parameter
I am new to Spring Boot. As I understand how constructor injection works then I can't tell why HelloController works - index method is not a constructor so where/why cat object instance is created? Would be glad to get some documentation or articles…

Cepheon
- 50
- 8
1
vote
2 answers
Put value of application.properties in annotation @GetMapping
I'm tried to call a get http response with spring boot, and I have a value of url in application.properties, I'm tried to call this value in annotation @GetMapping like that :
@GetMapping("${service.url}")
But Spring boot says "Cannot resolve…

Charles
- 11
- 1