看看这个问题\大家帮忙解决
我在用Struts的validation校验时、因为我的页面有两个、都是相同的form、但是现在我在第一张页面会校验、第二张页面就不会了、我想问问是什么原因?
如:下面是我的第二张页面的内容
<table width= "770 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " class= "right_table ">
<tr>
<td height= "30 " colspan= "3 ">
<table width= "770 " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td width= "117 "> <img src= "${ctx}/broker/images/right_title_setting.gif " width= "117 " height= "30 " alt= " "> </td>
<td class= "conner_rt "> <table width= "100% " height= "30 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "29% "> </td>
<td width= "16% " class= "title_right "> 工商物业 </td>
<td width= "55% "> </td>
</tr>
</table> </td>
</tr>
</table> </td>
</tr>
<tr>
<td class= "conner_lb "> </td>
<td width= "713 "> <table id= "__01 " width= "100% " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td> <img name= "shim " src= " " width= "1 " height= "16 " alt= " "> </td>
</tr>
<tr>
<td valign= "top "> <table width= "100% " border= "0 " cellpadding= "0 " cellspacing= "0 " class= "right_branch ">
<tr>
<td width= "100% " align= "center " > <table width= "93% " border= "0 " cellpadding= "0 " cellspacing= "0 " class= "netset_title ">
<tr>
<html:form action= "/broker/gswyNet.do?method= " onsubmit= "return validateBrokergswynetForm(this) ">
//这是用到的validateBrokergswynetForm
<html:hidden property= "id " value= "${id} "/>
<html:hidden property= "ordid " value= "${ordid} "/>
<html:hidden property= "childId " value= "${childId} " />
<html:hidden property= "city " value= "${city} "/>
<html:hidden property= "townid " value= "${townid} "/>
<td class= "td1 "> 地址/价格/日期/出租 </td>
<td class= "td1 "> 销售类别/物业类型/物业情况 </td>
<td class= "td1 "> 收入支出/生意情况 </td>
<td class= "selected "> 业主/经济/备注 </td>
</tr>
</table> </td>
</tr>
<tr>
<td class= "right_title2 "> 业主 (带 <img src= "${ctx}/broker/images/red_dot.gif " width= "18 " height= "17 "> 的栏目必须填写) </td>
</tr>
<tr>
<td> <img src= "${ctx}/broker/images/red_dot.gif " width= "18 " height= "17 "> 业主姓名:
<html:text property= "landlord " styleClass= "input_company2 " />
<html:reset styleClass= "button_2w "> 重 填 </html:reset>
<html:submit styleClass= "button_2w " property= "method " onclick= "return next( 'broker_gswy_four '); ">
保存
</html:submit>
</td>
</tr>
</table> </td>
</tr>
</html:form> <html:javascript formName= "brokergswynetForm "/>
</table>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function next(path){
f=document.forms[0];
if(f.townid.value== "请选择 ")
{
alert( "请选择镇 ");
return false;
}
else{
var act = "${ctx}/broker/gswyNet.do?method= "
act+= "addGswyPost "+ "&path= "+path
document.brokergswynetForm.action=act;
}
}
//-->
</SCRIPT>
大家给看看是什么原因?
[解决办法]
跨页表单验证吧.
<html:javascript formName= "brokergswynetForm "/> 加个page属性.
<html:javascript formName= "brokergswynetForm " page= "2 "/> ,
还有在validation.xml中所有属性都要有page属性来说明该属性在第几页上.
你的问题说明的很不详细.代码只贴这么一点,很难知道是什么错误的.以上的是我猜测.