带@ModelAttribute创建的参数对象会被添加到Model对象中。注解在参数上时,可以从Form表单或URL参数中获取参数并绑定到model中。
<div class="logo f-l">
<a href="${ctx}/index/text.do?abc=123" title="中林logo"><img src="${pageContext.request.contextPath}/images/zl2-01.gif" /></a>
<p>${abc}</p>
</div>
@RequestMapping("/text")
public String test(@ModelAttribute("abc") String abc){
System.err.println(abc);
return "index";
}
上述代码中,处理url请求时,会创建String对象,值为url请求中的参数“abc”的值,并将该对象添加到Model中,在jsp中可以在request中引用该对象