jsp页面里的form必须用标签形式<html:form 才可以,否则会出错。
form里面的元素无所谓,不用struts标签也可以使用。
页面里的form元素的名称必须第一个字母小写,而且必须对应的actionForm里有它的get/set方法才可以,例如:<input name="myName"> ActionForm里面必须有getMyName和setMyName方法对应。
可以用haspMap之类的构造多个参数的链接,
比如:
HashMap nextValues = new HashMap();
nextValues.put("searchKey", searchKey);
nextValues.put("txtSearch", txtSearch);
nextValues.put("type", searchType);
nextValues.put("flag", "true");
httpServletRequest.setAttribute("nextValues", nextValues);
而在页面里可以这样调用:
<html:link page="/myAction.do" name="nextValues">
最终生成的效果是:
<a href="/myAction.do?type=buy&flag=true&searchKey=industry&txtSearch=">下一页</a>
form的默认名字是对应的ActionForm,如果要自行指定名字,则必须写上type属性:
<html:form action="/myAction.do" method="post" name="form1" type="com.form.myActionForm">