zoukankan      html  css  js  c++  java
  • 数据传递-------@PathVariable

    package com.wh.handler;
    /**
     * 通过@PathVariable可以绑定占位符参数到方法参数中,例如
     * @PathVariable("userId") Long userId
     */
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    @Controller
    @RequestMapping("/{userid}")
    public class TestPathVariable {
    	/**
    	 * @PathVariable("userid") String uname
    	 * 表示将URL中占位符为userid绑定给方法参数中的uname这个变量名
    	 */
    	@RequestMapping("/hello.action")
    	public String h1(@PathVariable("userid") String uname){
    		//绑定{xxx}占位符的URL
    		System.out.println("userid   "+uname);
    		return "sus.jsp";
    	}
    	
    	/**
    	 * @PathVariable String userid
    	 * 表示将URL中占位符为userid绑定给方法参数中的userid这个变量名
    	 * 与第一个的区别:第一个给@PathVariable指定是哪个占位符,第二个是根据参数名来指定是哪个占位符
    	 */
    	@RequestMapping("/hello2.action")
    	public String h2(@PathVariable String userid){
    		//绑定{xxx}占位符的URL
    		System.out.println("userid2   "+userid);
    		return "sus.jsp";
    	}
    }
    

     

    userid2   pathvariable 

  • 相关阅读:
    6 、 图论—NP 搜索
    5 、 数值计算
    4 、 数论
    3 、 结构
    2 、 组合
    1 、 几何
    Dikstra 堆优化板子
    SPFA板子
    C++优先队列例子
    一些类使用的模板
  • 原文地址:https://www.cnblogs.com/1020182600HENG/p/6911470.html
Copyright © 2011-2022 走看看