带有占位符的URL映射

带有占位符的URL映射_第1张图片

 

package com.zhangpn.hello;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class Hello {
    @RequestMapping(value="/hello/{id}",method=RequestMethod.GET)
    public String Hello(@PathVariable(value="id") int id) {
        System.out.println("**************hello*******************"+id);
        return "success";
    }
}

http://localhost:8080/SpringMVC/hello/45

id就被赋值为45

 

转载于:https://www.cnblogs.com/batj/p/9198158.html

你可能感兴趣的:(带有占位符的URL映射)