Questions tagged [request-mapping]

Issues regarding usage of Spring MVC @RequestMapping methods

348 questions
4
votes
1 answer

Extend class level RequestMapping with custom annotation

I would like to create a custom annotation in my Spring Boot application which always adds a prefix to my class level RequestMapping path. My Controller: import com.sagemcom.smartvillage.smartvision.common.MyApi; import…
Csuki
  • 1,297
  • 8
  • 21
4
votes
3 answers

Spring MVC Diffrence between Path & Variable in @RequestMapping Annotation

I would like to know what are the differences between Path and Variable in Spring MVC in the Controller class. @RequestMapping("/home") @RequestMapping(value = "/home") @RequestMapping(path = "/home") Base on the Spring Documentation Spring 5…
4
votes
1 answer

Is it possible to get the RequestMethod-verb in a custom PreAuthorize method?

I'm using a custom access checker with @PreAuthorize: @RestController @RequestMapping("/users") public class Users { @PreAuthorize("@customAccessChecker.hasAccessToMethod('USERS', 'GET')") @RequestMapping(method = RequestMethod.GET) …
4
votes
2 answers

Multiple requestmapping value with path variables from thymeleaf

I have to send two data from thymeleaf to controller like this in a th:href:

Utku Soytaş
  • 1,475
  • 2
  • 19
  • 30
4
votes
3 answers

Spring does not discover @RequestMapping annotation for a new context at runtime

I just tried to develop a plugin system for my spring boot web application. The application is deployed on a tomcat server using the root context path. The plugin system allows me to load specially prepared jar files at runtime. The system should…
Tommy Schmidt
  • 1,224
  • 1
  • 16
  • 30
4
votes
2 answers

Spring MVC 3: same @RequestMapping in different controllers, with centralised XML URL mapping (hybrid xml/annotations approach)

I like to keep all my mapping in the same place, so I use XML config: /video/**=videoControllerr …
laffuste
  • 16,287
  • 8
  • 84
  • 91
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 { …
3
votes
3 answers

How to prepend some text to all controller URL in Spring

We have some already developed REST APIs in SpringBoot. Now we want to prepend some text (version of API eg /v1/) to all the @RequestMapping. Is there any way of doing this except prepending /v1/ to every @RequestMapping example: Current…
Mehraj Malik
  • 14,872
  • 15
  • 58
  • 85
3
votes
4 answers

MethodArgumentTypeMismatchException in spring boot

I try to delete a user by getting id in url with an error: Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: I change int id to String id, but then…
K.Nehe
  • 424
  • 10
  • 22
3
votes
3 answers

Spring MVC (Spring Boot) - RequestMapping inheritance

Edit: please read the question curefully, I don't need answers that repeat what I wrote. Looking aroung the web I found quite a confusion about this subject. What I'm looking for is a nice way to extend the value of a Controller's RequestMapping…
LppEdd
  • 20,274
  • 11
  • 84
  • 139
3
votes
2 answers

Get @RequestMapping value of different method in same controller

Using Spring Boot, I have a couple methods in my RegisterController which handles new user registration. The createNewUser method is responsible for saving the new user to the database and sending a confirmation e-mail containing a link that has a…
A_B
  • 1,009
  • 3
  • 15
  • 37
3
votes
1 answer

SpringBoot - @RequestMapping(name = "/home") - @RequestMapping(value = "/home")

I have some issues with Spring Boot. When im using @RequestMapping(value = "/home"), everything works fine for me. But when im using @RequestMapping(name = "/home"), my site won't show up. So my question is: What is the difference between…
Darkstar
  • 53
  • 4
3
votes
2 answers

How to map all requests to single controller method in spring?

I am new to spring. I want to map all the requests to single controller method. That's why I have specified following requestmapping @RequestMapping ( value="/PnPanel.go/CData/**", method={RequestMethod.GET, RequestMethod.POST} ) But still…
Mangu Singh Rajpurohit
  • 10,806
  • 4
  • 68
  • 97
3
votes
1 answer

Custom @RequestMapping annotation

I have few methods in my spring controllers which are mapped on the same path, example. @RequestMapping(value = "/{id}", method = RequestMethod.GET) protected ResourceDTO getById(@PathVariable int id) { return super.getById(id); …
Manza
  • 3,427
  • 4
  • 36
  • 57
3
votes
3 answers

Spring Mapping Url to Controller and View

I have the standard Spring 4.x files in Netbeans 8.0.2. I added a controller, RegisterController.java in the controllers-package. I also added one model, a User, with some basic information about the user. Next I made 2 .jsp files, Registration.jsp…
jdepypere
  • 3,453
  • 6
  • 54
  • 84
1 2
3
23 24