简体   繁体   English

调用execAndWait拦截器后,重定向到struts.xml操作中未定义的页面

[英]Getting redirected to page which is not defined in struts.xml action after calling execAndWait interceptor

After uploading file to server the server do some processing which takes some time. 将文件上传到服务器后,服务器需要一些处理,这需要一些时间。 Hence I'm using execute and wait interceptor to prevent time out. 因此,我使用执行等待拦截器来防止超时。

But the problem is once the execAndWait is called the page is getting redirected to exception.jsp but on the server end I'm not getting any exception at all. 但是问题是,一旦execAndWait被调用,页面就会被重定向到exception.jsp,但是在服务器端,我根本没有任何异常。 The process in running smoothly at server end. 在服务器端平稳运行的过程。

Also there is no result defined for exception.jsp in struts.xml. 在struts.xml中也没有为exception.jsp定义结果。

Struts.xml Struts.xml

  <action name="Process" class="fpoActions.Process" method="execute">
        <interceptor-ref name="defaultStack">
            <param name="fileUpload.maximumSize">150971520</param>
        </interceptor-ref>
        <interceptor-ref name="completeStack" />
        <interceptor-ref name="execAndWait" />
        <result name="wait">WEB-INF/fpo/longRunningAction-wait.jsp</result>
        <result name="success">WEB-INF/fpo/DownloadFpo.jsp</result>
        <result name="input">WEB-INF/fpo/fpoAnalysis.jsp</result>
    </action>

Action class 动作课

public String execute(){

        String appPath=request.getServletContext().getRealPath("")+"\\WEB-INF\\Data";
        try{
            System.out.println("DestinationLoc:"+appPath);
            System.out.println("Source File Name:"+fileFileName);
            File destFile  = new File(appPath, fileFileName);
            System.out.println(month+" "+year);
            FileUtils.copyFile(file, destFile);
            System.out.println("File Copied");
            System.out.println(destFile.getAbsolutePath());
            System.out.println(appPath);

            String t=utils.LogUtils.generateData(month,year,appPath,destFile.getAbsolutePath(),appPath);

            System.out.println("OutPut:"+t);
            System.out.println(new File(t).exists());
        }catch(Exception ex){
            addActionMessage("User Attributes file is not valid!!");
            ex.printStackTrace();
            return "input";
        }
        return "success";
    }

longRunningAction-wait.jsp longRunningAction-wait.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<head>
  <title>Processing</title>
  <meta charset="utf-8">
  <meta http-equiv="refresh" content="5;url=<s:url includeParams="all" />"/>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
 <style type="text/css">
  div#header,div#footer,div#content,div#post {
    border:1px solid grey;
    margin:5px;margin-bottom:5px;padding:8px;
    background-color:white;
}
div#header,div#footer {
    color:white;background-color:#444;margin-bottom:5px;
}
div#footer {
   position:fixed;
   left:0px;
   bottom:0px;
   height:30px;
   width:100%;
   background:#444;
}
  .logoutLblPos{

   position:fixed;
   left:10px;
   top:5px;
}
</style>
</head>
<body>
<div id="header">
<h1 align="center"> Automation</h1>
</div>
<div class="container">
  <h2 align="center">Please Wait while we process your Data...</h2>
  <div class="progress" align="center">
    <div align="center" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%">
      40%
    </div>
  </div>
</div>
<div id="footer">

</div>
</body>
</html>

Issue resolved after making following changes in struts.xml 在struts.xml中进行以下更改后,问题已解决

Removed completeStack interceptor and replaced defaultStack with completeStack interceptor. 删除了completeStack拦截器,并用completeStack拦截器替换了defaultStack。

 <action name="Process" class="fpoActions.Process" method="execute">
            <interceptor-ref name="completeStack">
                <param name="fileUpload.maximumSize">150971520</param>
            </interceptor-ref>
            <interceptor-ref name="execAndWait" />
            <result name="wait">WEB-INF/fpo/longRunningAction-wait.jsp</result>
            <result name="success">WEB-INF/fpo/DownloadFpo.jsp</result>
            <result name="input">WEB-INF/fpo/fpoAnalysis.jsp</result>
        </action>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM