该
RequestAttribute是什么,但你在表单提交已传递的参数。让我们看一个示例
假设我有以下表格
<form action="..."><input type=hidden name=param1 id=param1 value=test/></form>
现在,如果我有下面的控制器,它与请求的URL映射,并与下面的表单提交映射。
@Controllerpublic class CustomArgumentController {@ModelAttributevoid beforeInvokingHandlerMethod(HttpServletRequest request) { request.setAttribute("foo", "bar");}@RequestMapping(value="/data/custom", method=RequestMethod.GET)public @ResponseBody String custom(@RequestAttribute("param1") String param1 ) { // Here, I will have value of param1 as test in String object which will be mapped my Spring itself}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)