带有占位符的URL映射

 

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

 

相关文章:

  • 2022-01-25
  • 2022-12-23
  • 2021-10-10
  • 2022-02-12
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-11
  • 2021-07-01
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-09-09
相关资源
相似解决方案