当存在数据时,jquery 网格在 struts2 中产生 "Could not find action or result"

jquery grid results in "Could not find action or result" in struts2 when data is present

我有工作项目,但在升级 java、tomcat 和少数库后,内部 jquery-grid 之一停止工作。 (是的,外部 "jsonPatientAppointments" 仍在工作)如果在这种情况下没有数据,它不会抛出任何错误,但如果在这种情况下存在数据 struts2 操作将抛出 "Could not find action or result"。

我的行动class是

   @ParentPackage(value = "patient")
 public class JsonAppointmentHistoryAction extends ActionSupport implements 
 SessionAware
{

private static final long   serialVersionUID    = 5078263227068533593L;
private static final Logger log = Logger.getLogger(JsonAppointmentHistoryAction.class);
private List<PatientAppointmentBkp>      gridModel;
private List<PatientAppointmentBkp>      refPatientAppointments;
private Integer             rows             = 0;
private Integer             page             = 0;
private Integer             total            = 0;
private Integer             record           = 0;
private String              sord;
private String              sidx;
private String              searchField;
private String              searchString;
private String              searchOper;
private boolean             loadonce         = false;
private Map<String, Object> session;
private int appointmentNo;


private int id;

    @Actions({
      @Action(value = "/jsonAppointmentHistory", results = {
    @Result(name = "success", type = "json")
      })
    })
    public String execute(){
          log.warn("Page " + getPage()+" Rows " + getRows() +" Sorting Order "+ getSord()+" Index Row :" + getSidx());
        log.warn("Search :" + searchField + " " + searchOper + " " + searchString);

          log.debug("Build new List");
          refPatientAppointments = getAppointmentHisotoryList();
setRecord(PatientAppointmentHisDao.getPatientAppointmentHisCount(refPatientAppointments));

        int to = (getRows() * getPage());
        int from = to - getRows();
        to=to-1;
        if (to > getRecord()) to = getRecord();
        log.warn("from ==="+from +"  to====="+to);
        if (loadonce)
        {
          setGridModel(refPatientAppointments);
        }
        else
        {
            setGridModel(PatientAppointmentHisDao.getPatientAppointmentHis(refPatientAppointments, from, to));

        }

        setTotal((int) Math.ceil((double) getRecord() / (double) getRows()));



        return SUCCESS;
    }

    public List<PatientAppointmentBkp> getRefPatientAppointments() {
        return refPatientAppointments;
    }

    public void setRefPatientAppointments(
            List<PatientAppointmentBkp> refPatientAppointments) {
        this.refPatientAppointments = refPatientAppointments;
    }

    public String getJSON()
      {
        return execute();
      }

      /**
       * @return how many rows we want to have into the grid
       */
      public Integer getRows()
      {
        return rows;
      }

      /**
       * @param rows
       *          how many rows we want to have into the grid
       */
      public void setRows(Integer rows)
      {
        this.rows = rows;
      }

      /**
       * @return current page of the query
       */
      public Integer getPage()
      {
        return page;
      }

      /**
       * @param page
       *          current page of the query
       */
      public void setPage(Integer page)
      {
        this.page = page;
      }

      /**
       * @return total pages for the query
       */
      public Integer getTotal()
      {
        return total;
      }

      /**
       * @param total
       *          total pages for the query
       */
      public void setTotal(Integer total)
      {
        this.total = total;
      }

      /**
       * @return total number of records for the query. e.g. select count(*) from
       *         table
       */
      public Integer getRecord()
      {
        return record;
      }

      /**
       * @param record
       *          total number of records for the query. e.g. select count(*) from
       *          table
       */
      public void setRecord(Integer record)
      {

        this.record = record;

        if (this.record > 0 && this.rows > 0)
        {
          this.total = (int) Math.ceil((double) this.record / (double) this.rows);
        }
        else
        {
          this.total = 0;
        }
      }

      /**
       * @return an collection that contains the actual data
       */
      public List<PatientAppointmentBkp> getGridModel()
      {
        return gridModel;
      }

      /**
       * @param gridModel
       *          an collection that contains the actual data
       */
      public void setGridModel(List<PatientAppointmentBkp> gridModel)
      {
        this.gridModel = gridModel;
      }

      /**
       * @return sorting order
       */
      public String getSord()
      {
        return sord;
      }

      /**
       * @param sord
       *          sorting order
       */
      public void setSord(String sord)
      {
        this.sord = sord;
      }

      /**
       * @return get index row - i.e. user click to sort.
       */
      public String getSidx()
      {
        return sidx;
      }

      /**
       * @param sidx
       *          get index row - i.e. user click to sort.
       */
      public void setSidx(String sidx)
      {
        this.sidx = sidx;
      }

      public void setSearchField(String searchField)
      {
        this.searchField = searchField;
      }

      public void setSearchString(String searchString)
      {
        this.searchString = searchString;
      }

      public void setSearchOper(String searchOper)
      {
        this.searchOper = searchOper;
      }

      public void setLoadonce(boolean loadonce)
      {
        this.loadonce = loadonce;
      }

      public void setSession(Map<String, Object> session)
      {
        this.session = session;
      }



    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAppointmentNo() {
        return appointmentNo;
    }

    public void setAppointmentNo(int appointmentNo) {
        this.appointmentNo = appointmentNo;
    }

    private List<PatientAppointmentBkp> getAppointmentHisotoryList(){
        List<PatientAppointment> refAppRecords = new ArrayList<PatientAppointment>();
        PatientAppointment app = new PatientAppointment();
        if (refPatientAppointments == null){
            refPatientAppointments = new ArrayList<PatientAppointmentBkp>();
        }
        Object list = session.get("myApplist");
        int myPage = (int) session.get("myAppPage");
        int myRows = (int) session.get("myAppRows");
        if (list != null)
        {
            refAppRecords = (List<PatientAppointment>) list;
            app = refAppRecords.get(((myRows*(myPage-1))+id)-1);
        }

        refPatientAppointments = PatientAppointmentHisDao.buildAppList(app.getAppointNo());
        return refPatientAppointments;
    }

    public String getSearchField() {
        return searchField;
    }

    public String getSearchString() {
        return searchString;
    }

    public String getSearchOper() {
        return searchOper;
    }

    public boolean isLoadonce() {
        return loadonce;
    }


}

JSP代码

<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/struts-jquery-tags" prefix="sj" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<link href="/HospitalCare/css/style.css" rel="stylesheet" type="text/css">
<link href="/HospitalCare/css/menu.css" rel="stylesheet" type="text/css">

<div align="center">
<s:url id="remoteurl" action="jsonPatientAppointments">
<s:param name="patientId" value="%{patientId}"></s:param>
</s:url>
<s:url id="appointdetailsurl" action="jsonAppointmentHistory" />
<s:url id="editurl" action="edit-grid-entry"/>

<sjg:grid
    id="appointmentNo"
    caption="Appointment Records"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="gridModel"
    navigatorView="true"
    rowList="10,15,20"
    rowNum="15"
    rownumbers="true"
    viewrecords="true"
>
<sjg:grid 
        id="orderssubgridtable" 
        subGridUrl="%{appointdetailsurl}"
        gridModel="gridModel"
        rowNum="15"
        dataType="json"
        pager="true"
        navigatorView="true"
        rowList="10,15,20"
        footerrow="true"
        rownumbers="true"
        viewrecords="true"
    >
        <sjg:gridColumn name="appointmentDate" index="appointmentDate" 
  width="200" formatter="date" formatoptions="{newformat : 'd/m/Y H:i', 
 srcformat : 'Y-m-d H:i:s'}" title="Appintment Date" editable="false" 
 edittype="text" sortable="true" search="false"/>
        <sjg:gridColumn name="status" index="status" title="Status" 
 sortable="false" hidden="false"/>
        <sjg:gridColumn name="createDate" index="createDate" width="200" 
 formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}"  
 formatter="date" title="Scheduled On"  search="false" sortable="false" 
 hidden="false"/>
        <sjg:gridColumn name="modifyDate" index="modifyDate" width="200" 
 formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}" 
 formatter="date" title="Rescheduled On"  search="false" sortable="false" 
 hidden="false"/>
    </sjg:grid>
    <sjg:gridColumn name="appointmentDate" index="appointmentDate" 
   width="200" formatter="date" formatoptions="{newformat : 'd/m/Y H:i', 
  srcformat : 'Y-m-d H:i:s'}" title="Appintment Date" editable="false" 
  edittype="text" sortable="true" search="false"/>
    <sjg:gridColumn name="status" index="status" title="Status" 
  sortable="false" hidden="false"/>
    <sjg:gridColumn name="createDate" index="createDate" width="200" 
 formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}"  
    formatter="date" title="Scheduled On"  search="false" sortable="false" 
 hidden="false"/>
    <sjg:gridColumn name="modifyDate" index="modifyDate" width="200" 
   formatoptions="{newformat : 'd/m/Y H:i', srcformat : 'Y-m-d H:i:s'}" 
 formatter="date" title="Rescheduled On"  search="false" sortable="false" 
 hidden="false"/>
 </sjg:grid>
   <br/>

</div>

它正在抛出以下错误 08:45:57,475 WARN Dispatcher:64 - 找不到操作或结果:/HospitalCare/patient/jsonAppointmentHistory.action?id=1&&search=false&nd=1504494957407&rows=15&page=1&sidx=&sord=asc& =1504494947623 没有为操作 org.arshiya.struts.action.patient.JsonAppointmentHistoryAction 和结果异常定义结果 在 com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373) 在 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275) 在 org.arshiya.hibernate.util.SessionCheck.intercept(SessionCheck.java:34) 在 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) 在 org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) 在 org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562) 在 org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 在 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) 在 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) 在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 在 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) 在 org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) 在 org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) 在 org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(来源不明) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(未知来源) 在 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 在 java.lang.Thread.run(未知来源)

根据

no result defined for action and result exception

我认为您的执行方法抛出一些异常。我可以推荐 Struts Global Exception Handling 看看会发生什么。