Struts 并通过 follow 标签传递参数,它是如何工作的?
Struts and passing params with follow tag, how is it working?
我有一个 jsp 页面,其代码如下:
<script language="JavaScript">
function doOK()
{
var form = getForm();
if(form.varianceIsZeroOrReroute.value == '<%=ReIMConstants.NO%>')
{
if(!confirm("<bean:message key="alert.confirm_resolution_variance_not_zero"/>"))
{
return;
}
}
form.saveAction.value = '<%=PriceReviewListForm.SAVE_ACTION_OK%>';
form.action = "priceReviewVarianceResolutionSave.do";
form.submit();
return true;
}
然后像这样
<tr class="gButtonRow">
<td colspan="4" align="center" class="gContentSection">
<html:button property="Back" styleClass="gButton" onclick="back();"><bean:message key="button.back"/></html:button>
<html:button property="OK" styleClass="gButton" onclick="doOK()"> <bean:message key="button.ok"/> </html:button>
<html:button property="Delete" styleClass="gButton" onclick="deleteRecords();"><bean:message key="button.delete"/></html:button>
<html:button property="ApplyAll" styleClass="gButton" onclick="doApplyAll();"><bean:message key="button.apply_all"/></html:button>
<html:button property="Cancel" styleClass="gButton" onclick="doCancel();"><bean:message key="button.cancel"/></html:button>
</td>
</tr>
</table>
所以,正如您在 doOK 中看到的那样,有对 priceReviewVarianceResolutionSave 路径的引用。在 struts-config.xml 中,路径描述如下:
<action path="/priceReviewVarianceResolutionSave"
type="org.springframework.web.struts.DelegatingActionProxy"
name="PriceReviewListForm" scope="session">
<forward name="failureInvoice"
path="/price_review_variance_resolution.jsp" />
<forward name="failureDocument"
path="/price_review_variance_resolution_dispute.jsp" />
<forward name="successFull" path="/price_review_list.jsp" />
<forward name="successMore"
path="/priceReviewDetailLoad.do" />
<forward name="successDone" path="/home.do?targetTab=t4" />
<forward name="successApplyAll"
path="/priceReviewListLoad.do" />
<forward name="detailMatch" path="/detailMatchBegin.do" />
<forward name="unauthorized_access"
path="/home.do?targetTab=t4" />
</action>
据我所知,它从表单中读取某种输入并根据它转到特定页面。例如,如果值为 "successApplyAll",则它会转到“/priceReviewListLoad.do”。但问题是我在 jsp 代码中没有看到任何关于 "successApplyAll" 的提及。所以我不明白在哪里可以找到将 "successApplyAll" 传递给 "priceReviewVarianceResolutionSave" 部分的代码。可以肯定的是,我错过了某些部分或弄错了。你能帮我解释一下我必须在哪里寻找这部分代码吗?谢谢!
转发名称用于内部操作以确定接下来发生的事情。
即使 grep
也可以帮助您找到该字符串在代码中的使用位置,即使完全缺乏 Struts 知识也是如此。也就是说:如果您正在处理 Struts 代码库,那么退后一步并至少学习一些基础知识可能是有意义的。
我有一个 jsp 页面,其代码如下:
<script language="JavaScript">
function doOK()
{
var form = getForm();
if(form.varianceIsZeroOrReroute.value == '<%=ReIMConstants.NO%>')
{
if(!confirm("<bean:message key="alert.confirm_resolution_variance_not_zero"/>"))
{
return;
}
}
form.saveAction.value = '<%=PriceReviewListForm.SAVE_ACTION_OK%>';
form.action = "priceReviewVarianceResolutionSave.do";
form.submit();
return true;
}
然后像这样
<tr class="gButtonRow">
<td colspan="4" align="center" class="gContentSection">
<html:button property="Back" styleClass="gButton" onclick="back();"><bean:message key="button.back"/></html:button>
<html:button property="OK" styleClass="gButton" onclick="doOK()"> <bean:message key="button.ok"/> </html:button>
<html:button property="Delete" styleClass="gButton" onclick="deleteRecords();"><bean:message key="button.delete"/></html:button>
<html:button property="ApplyAll" styleClass="gButton" onclick="doApplyAll();"><bean:message key="button.apply_all"/></html:button>
<html:button property="Cancel" styleClass="gButton" onclick="doCancel();"><bean:message key="button.cancel"/></html:button>
</td>
</tr>
</table>
所以,正如您在 doOK 中看到的那样,有对 priceReviewVarianceResolutionSave 路径的引用。在 struts-config.xml 中,路径描述如下:
<action path="/priceReviewVarianceResolutionSave"
type="org.springframework.web.struts.DelegatingActionProxy"
name="PriceReviewListForm" scope="session">
<forward name="failureInvoice"
path="/price_review_variance_resolution.jsp" />
<forward name="failureDocument"
path="/price_review_variance_resolution_dispute.jsp" />
<forward name="successFull" path="/price_review_list.jsp" />
<forward name="successMore"
path="/priceReviewDetailLoad.do" />
<forward name="successDone" path="/home.do?targetTab=t4" />
<forward name="successApplyAll"
path="/priceReviewListLoad.do" />
<forward name="detailMatch" path="/detailMatchBegin.do" />
<forward name="unauthorized_access"
path="/home.do?targetTab=t4" />
</action>
据我所知,它从表单中读取某种输入并根据它转到特定页面。例如,如果值为 "successApplyAll",则它会转到“/priceReviewListLoad.do”。但问题是我在 jsp 代码中没有看到任何关于 "successApplyAll" 的提及。所以我不明白在哪里可以找到将 "successApplyAll" 传递给 "priceReviewVarianceResolutionSave" 部分的代码。可以肯定的是,我错过了某些部分或弄错了。你能帮我解释一下我必须在哪里寻找这部分代码吗?谢谢!
转发名称用于内部操作以确定接下来发生的事情。
即使 grep
也可以帮助您找到该字符串在代码中的使用位置,即使完全缺乏 Struts 知识也是如此。也就是说:如果您正在处理 Struts 代码库,那么退后一步并至少学习一些基础知识可能是有意义的。