【发布时间】:2012-10-08 15:29:23
【问题描述】:
我需要在我的 java 方法上调用 href 链接。我的示例代码定义如下。完成我的逻辑后,我需要调用 URL。该 URL 用于打开 Excel 工作簿并将我们的 bean 值导入其中。
public void populateExcelReportValues(HttpServletRequest request, HttpServletResponse response) throws Exception
{
String METHOD_NAME = "populateExcelReportValues";
log.entering(CLASS_NAME, METHOD_NAME);
//Rating Element Id
String ratingElementIdForExcel = request.getParameter("ratingElementIdFromJSP");
//Instance Type Name
String instanceTypeForExcel = request.getParameter("instanceTypeFromJSP");
int ratingElementIdForExcelInt = 0;
String instanceTypeValueForExcel = "";
if(ratingElementIdForExcel != null && ratingElementIdForExcel.trim().length()>0)
{
ratingElementIdForExcelInt = Integer.parseInt(ratingElementIdForExcel);
System.out.println("ratingElementIdForExcelInt: "+ratingElementIdForExcelInt);
}
if(instanceTypeForExcel != null && instanceTypeForExcel.trim().length()>0)
{
instanceTypeValueForExcel = instanceTypeForExcel.trim();
System.out.println("instanceTypeValueForExcel: "+instanceTypeValueForExcel);
}
switch (ratingElementIdForExcelInt)
{
case 1: //ASN Accuracy - Rating Element ID - 1
weeklyDeliveryInstancesRatingElementQO = getASNAccuracyRatingElement(instanceTypeValueForExcel);
//return weeklyDeliveryInstancesRatingElementQO;
break;
default:
weeklyDeliveryInstancesRatingElementQO = new ArrayList<WeeklyDeliveryInstancesRatingElementQO>();
break;
}
//How to invoke this url to here
**(MultiTableExportServlet?multitablesId=WeeklyDeliveryInstances-Count&name=WeeklyDeliveryInstances-Count&type=excel)**
log.exiting(CLASS_NAME, METHOD_NAME);
}
在上面我的代码中,我显示为粗体以供您识别。
Jsp页面:
<display:table name="${weeklyDlvyInstancesDashboardReportForm.asnAccuracyListQO}" uid="asnAccuracyListUID" sort="list" defaultsort="1"
requestURI="/weeklyDlvyInstancesDashboardReportPre.do?method=httpGet" excludedParams="method"
decorator="com.ford.mpl.superg.decorator.WeeklyDeliveryInstancesTypeTableDecorator" keepStatus="true">
<%@include file="/jsp/include/displaytag.jsp"%>
<c:set value="${asnAccuracyListUID.firstWeekOfCountLabel}" var="asnAccuracyFirstWeekOfCount"/>
<c:set value="${asnAccuracyListUID.secondWeekOfCountLabel}" var="asnAccuracySecondWeekOfCount"/>
<c:set value="${asnAccuracyListUID.thirdWeekOfCountLabel}" var="asnAccuracyThirdWeekOfCount"/>
<c:set value="${asnAccuracyListUID.fourthWeekOfCountLabel}" var="asnAccuracyFourthWeekOfCount"/>
<c:set value="${asnAccuracyListUID.fifthWeekOfCountLabel}" var="asnAccuracyFifthWeekOfCount"/>
<c:set value="${asnAccuracyListUID.sixthWeekOfCountLabel}" var="asnAccuracySixthWeekOfCount"/>
<c:choose>
<c:when test="${asnAccuracyListUID.instanceTypeDescription != null && asnAccuracyListUID.instanceTypeDescription != 'Sum'}">
<display:column property="instanceTypeDescription" title="Instance Type" sortable="false"/>
</c:when>
<c:otherwise>
<display:column property="instanceTypeDescription" title="Instance Type" sortable="false" style="font-weight:bold;text-align:center"/>
</c:otherwise>
</c:choose>
<display:column property="firstWeekOfCount" title="${asnAccuracyFirstWeekOfCount}" sortable="false"/>
<display:column property="secondWeekOfCount" title="${asnAccuracySecondWeekOfCount}" sortable="false" />
<display:column property="thirdWeekOfCount" title="${asnAccuracyThirdWeekOfCount}" sortable="false" />
<display:column property="fourthWeekOfCount" title="${asnAccuracyFourthWeekOfCount}" sortable="false" />
<display:column property="fifthWeekOfCount" title="${asnAccuracyFifthWeekOfCount}" sortable="false" />
<display:column property="sixthWeekOfCount" title="${asnAccuracySixthWeekOfCount}" sortable="false"/>
</display:table>
</fieldset>
<export:multitables id="WeeklyDeliveryInstances-Count">
<export:table title="tablename" source="${weeklyDlvyInstancesDashboardReportForm.weeklyDeliveryInstancesRatingElementQO}">
<export:column property="shipCode" title="Ship Code" />
<export:column property="plantOrRecLoc" title="Plant/Rec Loc" />
<export:column property="instanceType" title="Instance Type" />
<export:column property="fordOrg" title="Ford Org" />
<export:column property="OrgType" title="Org Type" />
<export:column property="region" title="Region" />
<export:column property="shipDate" title="Ship Date" />
<export:column property="errorTransmitted" title="Error Transmitted" />
<export:column property="externalAlertNo" title="External Alert Number" />
<export:column property="asnNumber" title="ASN Number"/>
<export:column property="packingSlipNumber" title="Packing Slip Number"/>
</export:table>
</export:multitables>
【问题讨论】:
-
您的意思是要将用户的请求重定向到 Web 应用程序中名为 MultiTableExportServlet 的 servlet?或者你的意思是你想从你的 Java 代码中调用这个 servlet,然后继续处理用户的请求,例如使用你的 Struts Action 类?
-
@martin,我想从我的 java 方法中重定向 multitableexportservlet
-
web.xml 中 MultiTableExportServlet servlet 的 servlet-mapping 中的 servlet-name 是什么?是multitableexportservlet吗?
-
@martin,servlet 名称是 MultiTableExportServlet
-
servlet-mapping 中的 url-pattern 是什么?