首页 > 移动平台 > 详细

SpringMVC(七) RequestMapping 路径中带占位符的URL

时间:2017-01-13 22:32:23      阅读:318      评论:0      收藏:0      [点我收藏+]

使用方法:在@RequestMapping("/delete/{id}")中,通过{id}带入pathvariable,然后在方法中,通过@PathVariable("变量名称") Iteger id 的方式引入占位符。

 

控制器代码:

package com.tiekui.springmvc.handlers;

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

@Controller
public class TestPathVariable {
    @RequestMapping("/testparam/{id}")
    public String test(@PathVariable("id") Integer id){
        System.out.println(id);
        return "success";
    }
}

视图代码:

<a href="testparam/100">Test PathVariable</a>

 

SpringMVC(七) RequestMapping 路径中带占位符的URL

原文:http://www.cnblogs.com/zhoutiekui/p/6284154.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!