java - 在ActionForm(struts1.2.9)中完成我的逻辑后如何调用servlet?

标签 java servlets frameworks struts struts-1

目前使用的是Struts 1.2.9。在我的 actionForm 页面中,我有一些 switch 语句。结束此 switch 语句后,我如何从 ActionForm 页面调用 servlet。 我的代码是,

public void populateExcelReportValues(HttpServletRequest request) 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);
    }
    if(instanceTypeForExcel != null && instanceTypeForExcel.trim().length()>0)
    {
        instanceTypeValueForExcel = instanceTypeForExcel.trim();
    }
    switch (ratingElementIdForExcelInt) 
    {
        case 1: //ASN Accuracy - Rating Element ID - 1 
                weeklyDeliveryInstancesRatingElementQO = getASNAccuracyRatingElement(instanceTypeValueForExcel);
                //return weeklyDeliveryInstancesRatingElementQO;
                break;
        case 2: //Manual ASN - Rating Element ID - 2
                weeklyDeliveryInstancesRatingElementQO = getManualASNRatingElement(instanceTypeValueForExcel);
                break;
        case 3: //Packaging - Rating Element ID - 3 
                weeklyDeliveryInstancesRatingElementQO = getPackagingRatingElement(instanceTypeValueForExcel);
                break;
        case 4: //Behind Schedule - Rating Element ID - 4
                weeklyDeliveryInstancesRatingElementQO = getBehindScheduleRatingElement(instanceTypeValueForExcel);
                //return weeklyDeliveryInstancesRatingElementQO;
                break;
        case 5: //Cum Imbalance - Rating Element ID - 5
                weeklyDeliveryInstancesRatingElementQO = getCumImbalanceRatingElement(instanceTypeValueForExcel);
                break;
        case 6: //OverShipment - Rating Element ID - 6
                weeklyDeliveryInstancesRatingElementQO = getOverShipmentRatingElement(instanceTypeValueForExcel);
                break;
        case 7: //ASNTimeliness - Rating Element ID - 7
                weeklyDeliveryInstancesRatingElementQO = getASNTimelinessRatingElement(instanceTypeValueForExcel);
                //return weeklyDeliveryInstancesRatingElementQO;
                break;
        case 8: //UnAnsweredDDL Shortages - Rating Element ID -  8
                weeklyDeliveryInstancesRatingElementQO = getUnAnsweredDDLShortagesRatingElement(instanceTypeValueForExcel);
                break;
        case 9: //Supplier Delivery Contact Updates - Rating Element ID - 9
                weeklyDeliveryInstancesRatingElementQO = getSupplierDeliveryContactUpdatesRatingElement(instanceTypeValueForExcel);
                break;
        case 10: //Shipping Discrepancies - Rating Element ID - 10
                weeklyDeliveryInstancesRatingElementQO = getShippingDiscrepanciesRatingElement(instanceTypeValueForExcel);
                //return weeklyDeliveryInstancesRatingElementQO;
                break;
        case 13: //SDS Promise Accuracy - Rating Element ID - 13
                weeklyDeliveryInstancesRatingElementQO = getSDSPromiseAccuracyRatingElement(instanceTypeValueForExcel);
                break;
        case 15: //Behind Schedule Emergency Orders - Rating Element ID - 15
                weeklyDeliveryInstancesRatingElementQO = getBehindScheduleEmergencyOrdersRatingElement(instanceTypeValueForExcel);
                break;
        default:
                weeklyDeliveryInstancesRatingElementQO = new ArrayList<WeeklyDeliveryInstancesRatingElementQO>();
                break;
    }

    log.exiting(CLASS_NAME, METHOD_NAME);

    (Link)/MultiTableExportServlet?multitablesId=WeeklyDeliveryInstances-Count&amp;name=WeeklyDeliveryInstances-Count&amp;type=excel   

}

我突出显示了我要在 switch 语句执行后调用的代码。

最佳答案

request.getRequestDispatcher("other servlet").forward(request, response);

关于java - 在ActionForm(struts1.2.9)中完成我的逻辑后如何调用servlet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12948654/

相关文章:

java - 使用 hbm.xml 的 Hibernate 中主键的强制 setter

java - 无法在 Tomcat 项目的测试中连接 Java ServlextContext

tomcat - Heroku Java Tomcat ServletContextListener 不在 slugc 或重启时调用 contextDestroyed

java - 为什么无法导入属性文件

java - 可以用ant修改源码吗?

java - 私有(private)不可访问字段是否需要是最终的?

Python:如何在没有庞大框架的情况下创建简单的网页?

java - Apache Cocoon JAR 配置 - 我想使用 .class 文件!

frameworks - Spock + GEB 与机器人框架

java - org.hibernate.PropertyNotFoundException : Could not find a getter for