1. 利用@RequestParam

//courses/view?course=123 参数绑定
使用@RequestParam从路径获取变量,URL中参数传递方式为 HTTP地址后加上
?course=123
进行参数绑定。问号的后面部分就是请求参数部分,是要向请求路径提交的参数信息。
2. 利用@PathVariable

//本方法将处理 /courses/view3?courseId=123 形式的URL
使用@PathVariable从路径获取变量,URL中参数传递方式为 HTTP地址后加上
/参数值 如/123
进行参数绑定。
3. 利用HttpServletRequest

//本方法将处理 /courses/view3?courseId=123
使用HttpServletRequest.getParameter从路径获取变量,URL中参数传递方式为 HTTP地址后加上
?course=123
进行参数绑定。
网友评论