Answers for "@pathvariable spring boot"

3

@pathvariable spring boot

package com.zetcode.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyController {
  
    @RequestMapping(path="/{name}/{age}")
    public String getMessage(@PathVariable("name") String name, 
            @PathVariable("age") String age) {
        var msg = String.format("%s is %s years old", name, age);
        return msg;
    }
  
}
Posted by: Guest on July-19-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language