当数据存在时,jquery网格导致struts2中的“无法找到操作或结果”

时间:2017-09-04 03:59:39

标签: jquery struts2 struts2-jquery-grid

我有工作项目,但在升级java,tomcat和少数库之后,内部jquery-grid之一停止工作。 (是的,外部的“jsonPatientAppointments”仍在工作)如果在这种情况下没有数据,它不会抛出任何错误,但如果在这种情况下存在数据,struts2操作就会抛出“无法找到操作或结果”。

我的动作类是

   @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)     at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)     at 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)     at 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)     at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:637)     at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:318)     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)     at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     在java.lang.Thread.run(未知来源)

1 个答案:

答案 0 :(得分:0)

根据

  

没有为操作和结果异常定义结果

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