Struts标签<bean:define>可以定义一个变量,例<bean:define name="studentForm" property="classID" id="CID"/>这样就定义变量CID,其值是studentForm中的classID。
可以在JavaScript的方法中用<%=CID%>来引用这个变量了,可以用它来拼装URL,或者其他一些操作
例如
url='<%=request.getContextPath()%>/Student/student.do?state=add&classID=<%=CID%>'
注意:用<bean:define>定义的变量有一定的域,如果在Form标签中使用了<bean:define>,则这个变量只在Form标签中可用,如果你的JS方法定义在Form标签以外,则无法引用这个变量。