How can i pass multiple variables in the Url for the Spring controller?

webExplorer

I want to pass two variables in the url to my Spring Controller.

I'm trying to achieve this using the following code. The controller though reads just the second param.

What am i missing here?

@RestController
@RequestMapping("/service/getVars")
public class SpringServiceController {
    @RequestMapping(value = "/Id/{Id}/Name/{Name}", method = RequestMethod.GET)
    public String getGreeting(@PathVariable String Id, @PathVariable String Name) {
         //Both id and name now holds Name variables value. 
         System.out.println("Id: "+ Id + " >> Name: " + Name);

    }
} 

i/p: localhost:8080/service/getVars/Id/111/Name/222

o/p: Id: 222 >> Name: 222

Expected o/p: Id: 111 >> Name: 222

Sotirios Delimanolis

This might depend on the way you are compiling your source code. If the parameter names are not included in the byte code, I don't think the behavior of @PathVariable without a value attribute is defined. Add it explicitly

@RequestMapping(value = "/Id/{Id}/Name/{Name}", method = RequestMethod.GET)
public String getGreeting(@PathVariable(value = "Id") String Id, @PathVariable(value = "Name") String Name) {

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to pass a null value for a URL parameter to Spring MVC controller?

From Dev

How can I pass data to dompdf from controller?

From Dev

How do I pass an array of integer into spring controller?

From Dev

How can I pass the selected Kendo Menu Text to Controller

From Dev

How I can pass multiple parameters to URL in php

From Dev

How to pass multiple variables?

From Dev

How can I pass multiple variables into a template in Webpy?

From Dev

How can i pass multiple value another page in URL

From Dev

How Can I Pass Result of Foreach from Controller to View CodeIgniter

From Dev

How can I pass javascript variable to grails controller using remoteFunction

From Dev

How can I have multiple controller files?

From Dev

How can I pass a controller to a function

From Dev

how can i convince spring 4.2 to pass OPTIONS request through to the controller

From Dev

How can I pass multiple Json objects to ASP.net MVC controller?

From Dev

How can I pass variables in AngularJS from one controller to next in ASP MVC setup?

From Dev

How can I pass url params to templateUrl

From Dev

How can i pass variables in Zend?

From Dev

How to pass multiple values from the form to a controller using Spring MVC?

From Dev

How can I rewrite my controller URL?

From Dev

How can I pass multiple variables into a template in Webpy?

From Dev

how i pass multiple variables from view to controller in codeigniter inside form_open

From Dev

How to bind multiple path variables in Spring MVC Controller?

From Dev

pass multiple variables to the controller

From Dev

How can I pass variables in AngularJS from one controller to next in ASP MVC setup?

From Dev

How can I pass variables to multiple objects in unity c#

From Dev

how can I access controller by URL?

From Dev

how to pass variables from controller to controller in prestashop?

From Dev

Spring Boot Application - How can I pass data (list in list) from controller to Thymeleaf based on current object?

From Dev

How do i pass an object from jsp to controller with spring

Related Related

  1. 1

    How to pass a null value for a URL parameter to Spring MVC controller?

  2. 2

    How can I pass data to dompdf from controller?

  3. 3

    How do I pass an array of integer into spring controller?

  4. 4

    How can I pass the selected Kendo Menu Text to Controller

  5. 5

    How I can pass multiple parameters to URL in php

  6. 6

    How to pass multiple variables?

  7. 7

    How can I pass multiple variables into a template in Webpy?

  8. 8

    How can i pass multiple value another page in URL

  9. 9

    How Can I Pass Result of Foreach from Controller to View CodeIgniter

  10. 10

    How can I pass javascript variable to grails controller using remoteFunction

  11. 11

    How can I have multiple controller files?

  12. 12

    How can I pass a controller to a function

  13. 13

    how can i convince spring 4.2 to pass OPTIONS request through to the controller

  14. 14

    How can I pass multiple Json objects to ASP.net MVC controller?

  15. 15

    How can I pass variables in AngularJS from one controller to next in ASP MVC setup?

  16. 16

    How can I pass url params to templateUrl

  17. 17

    How can i pass variables in Zend?

  18. 18

    How to pass multiple values from the form to a controller using Spring MVC?

  19. 19

    How can I rewrite my controller URL?

  20. 20

    How can I pass multiple variables into a template in Webpy?

  21. 21

    how i pass multiple variables from view to controller in codeigniter inside form_open

  22. 22

    How to bind multiple path variables in Spring MVC Controller?

  23. 23

    pass multiple variables to the controller

  24. 24

    How can I pass variables in AngularJS from one controller to next in ASP MVC setup?

  25. 25

    How can I pass variables to multiple objects in unity c#

  26. 26

    how can I access controller by URL?

  27. 27

    how to pass variables from controller to controller in prestashop?

  28. 28

    Spring Boot Application - How can I pass data (list in list) from controller to Thymeleaf based on current object?

  29. 29

    How do i pass an object from jsp to controller with spring

HotTag

Archive