如何从另一个应用程序的操作文件调用应用程序

时间:2012-10-23 15:46:56

标签: java java-ee struts struts-validation

旧应用程序中的动作文件

package com.xxxxxxx.rbc.rollup.ui.actions.loangroup;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionRedirect;

import com.fanniemae.rbc.rollup.ui.UIConstants;

public class SnifferToolAction extends Action {
    public ActionForward execute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            throws Exception {


        HttpSession session = request.getSession();
        String user = (String)session.getAttribute(UIConstants.KEY_USER);

        String subAction = request.getParameter("subAction");   
        ActionRedirect redirect = null;


        if ("display".equalsIgnoreCase(subAction)){ 
            redirect = new ActionRedirect(mapping.findForward("display"));

            return redirect;
        }

        return mapping.findForward("home");


    }
}

以上是主应用程序中可用链接的动作文件。当我们点击链接时,位于主文件夹但不同子文件夹的新应用程序应该点击并运行该过程。 以下是动作文件调用的主文件。

不同申请表的主要文件:

package com.xxxxxxxxx.alexrbc.qrmlog;

import java.io.*;
import java.util.*;
import com.fanniemae.alexrbc.qrmlog.keyword.*;
import com.fanniemae.alexrbc.qrmlog.file.*;

public class Sniffer {

private static void printUsage() {
    System.out.println("Usage: sniff <inc|exc> {searchText} userID keywordFile QRMLogFile [QRMLogFile...]");    
}

/**
 * @param args
 */
public static void main(String[] args) {
    if (args.length < 4) {
        printUsage();
        System.exit(1);
    }

    int argIdx = -1;

    argIdx++;
    int parseMode = 0;
    String searchText = null;
    if ("inc".equals(args[argIdx])) {
        parseMode = QRMLogFile.QRM_LOG_FILE_PARSE_MODE_INCLUDE;
    } else if ("exc".equals(args[argIdx])) {
        parseMode = QRMLogFile.QRM_LOG_FILE_PARSE_MODE_EXCLUDE;
        argIdx++;
        searchText = args[argIdx];
    } else {
        System.out.println("Invalid mode argument - " + args[argIdx]);
        printUsage();
        System.exit(1);
    }

    argIdx++;
    String userId = args[argIdx];

    argIdx++;
    QRMKeywordFile qrmKeywordFile = null;
    try {
        qrmKeywordFile = new QRMKeywordFile(args[argIdx]);
    } catch (QRMKeywordException e) {
        System.err.println("Invalid QRM keyword file - " + args[argIdx]);
        System.err.println(e.getMessage());
        System.exit(2);
    }

    argIdx++;
    ArrayList<QRMLogFile> qrmLogFileList = new ArrayList<QRMLogFile>();
    for (; argIdx < args.length; argIdx++) {
        try {
            QRMLogFile qrmLogFile = new QRMLogFile(parseMode, searchText, userId, args[argIdx]);
            qrmLogFileList.add(qrmLogFile);
        } catch (QRMLogFileException e) {
            System.err.println("Invalid QRM log file - " + args[argIdx]);
            System.err.println(e.getMessage());
        }
    }

    ArrayList<QRMKeyword> qrmKeywordList = null;
    try {
        qrmKeywordList = QRMKeywordManager.getKeywordList(qrmKeywordFile);

        //for (QRMKeyword qrmKeyword : qrmKeywordList) {
        //  System.out.println(qrmKeyword);
        //}
    } catch (QRMKeywordException e) {
        System.err.println("Invalid QRM keyword file - " + qrmKeywordFile.getKeywordPath());
        System.err.println(e.getMessage());
        System.exit(3);
    } catch (IOException e) {
        System.err.println("Error in getting QRM keyword list from " + qrmKeywordFile.getKeywordPath());
        System.err.println(e.getMessage());
        e.printStackTrace();
        System.exit(3);
    }

    String inputPath = null;
    String outputPath = null;
    for (QRMLogFile qrmLogFile : qrmLogFileList) {
        try {
            inputPath = qrmLogFile.getInputFile().getPath();
            System.out.println("Processing QRM input log file " + inputPath);

            QRMLogFileManager.processQRMLogFile(qrmLogFile, qrmKeywordList);

            outputPath = qrmLogFile.getOutputFile().getPath();
            System.out.println("Generated QRM output log file " + outputPath);
        } catch (QRMLogFileException e) {
            System.err.println("Error in processing QRM log file - " + inputPath);
            System.err.println(e.getMessage());
        } catch (IOException e) {
            System.err.println("Error in processing QRM log file - " + inputPath);
            System.err.println(e.getMessage());
            e.printStackTrace();
        }
    }
}

}

当我在操作文件中粘贴代码时,它没有找到包,错误正在弹出。有人会帮我....

感谢

1 个答案:

答案 0 :(得分:0)

您可以制作该应用程序的jar文件,然后将该应用程序jar文件包含在当前应用程序中。在该jar文件的帮助下,您可以访问当前应用程序中的一个应用程序。