Tuesday, July 11, 2006

Struts中如何写多参数链接

在View类的Class中准备一个返回HashMap的Method,例如:

public HashMap getRemoveLinkParams() {
HashMap map = new HashMap();
map.put("id", getId());
map.put("symbol", getSymbol());
return map;
}

在JSP中的链接写成:

<bean:define id="rlps" name="teamview" property="removeLinkParams"/>

<html:link action="/rosters/team/links?method=toremove" name="rlps">
remove
</html:link>

如果teamview中的id是42,symbol是“Jack London”,则出现在实际页面中的链接是:

/rosters/team/links?method=toremove&id=2&symbol=Jack London

(完)

No comments: