将请求url中包含的主键id取出来,进行操作

来源:互联网 发布:中科大软件学院学费 编辑:程序博客网 时间:2024/05/01 12:51

1.JSP页面上书写样式

function del(id){

    window.location.href="${pageContext.request.contextPath}/student/delete/"+id;

}

2.在controller中取得url中包含的id信息

@Controller
@RequestMapping("student")


@RequestMapping(value="/delete/{id}" ,method = RequestMethod.GET)
    public String studentDelete(Model m,HttpSession session,@PathVariable String id) {

      //方法体

}

总结:使用的诀窍是使用@PathVariable标签。

0 0
原创粉丝点击