朋友们好,这是我从网上下载的一个选课系统,现在struts2的配置出了问题,麻烦各位看看,能不能看出是哪里有问题了,出错在了点课程名想进入课程详细页面,结果出现错误了:首先是choiceclass.jsp 这个就是显示选课的地方,这是table:
<s:iterator value="allClasses" status="cs">
          <tr>
                  <td>
                      <s:property value="#cs.getIndex()+1+(pageNumber-1)*10"/>
                  </td>
                  <td>
                      <s:url  id="gets" action="skanCs">//就是这里出了错误
                          <s:param name="csId">
                      <s:property value="cname"/>
                      </s:param>
                      </s:url>
                      <s:a href="%{gets}"><s:property value="cname"/></s:a></td>
                  <td><s:property value="courTime"/></td>
                  <td><s:property value="roomId"/></td>
                  <td><s:property  value="teaId"/></td>
                  <td><s:a href="%{gets}">查看</s:a></td>
                  <td> <s:url  id="gets1" action="getdelteCs">
                          <s:param name="csId">                
                      </s:param>
                      </s:url><s:a href="%{gets1}">删除</s:a></td>
           </s:iterator></table>这是有关课程的action配置,struts2的xml文件中的
<!--查看所有课程-->
          <action name="cpageAction" class="AdminAction.CpageAction">
            <result type="redirect" >/allClasses?pageNumber=${pageNumber}&amp;totalPage=${totalPage}</result>   
        </action>
        <action name="allClasses" class="AdminAction.AllClasses">
           <result>/admin/choiceclass.jsp</result>   
        </action> 
        <!--获取课程-->
        <action name="skanCs" class="AdminAction.getCs"> //就是这里出了问题
        <result name="success">/admin/getClasses.jsp</result>
        <result name="input">/admin/error.jsp</result>
        </action> 
        <!--更新课程-->
        <action name="updataClasses" class="AdminAction.AddClasses" method="updataClasses">
        <result name="success">/admin/success.jsp</result>
        <result name="input">/admin/error.jsp</result>
        </action>
        <!--删除课程-->
        <action name="deleCs" class="AdminAction.DguClasses">
        <result name="success">/admin/success.jsp</result>
        <result name="input">/admin/error.jsp</result>
        </action>
然后这里是getCs的execute方法:
 public String execute() throws Exception {
      if(c.getClasses(getCsId())!=null){
          setCs(c.getClasses1(getCsId()));
            return SUCCESS;
        }
        return INPUT;
    }
现在数据库里面的表是可以的,查得到csid的,从学生端进的话是可以的(学生端用的是list的row来链接那种,可以实现,进入成功)
但用这个跳转的话就出错,都是返回了INPUT到了出错页面,所以有点不明白
以下是getclass和getCsId的方法:
    public Classes getClasses(int csId)
    {
        session=HibernateSessionFactory.getSession();
       Classes classes=(Classes)session.get(Classes.class, csId);
        HibernateSessionFactory.closeSession();
        return classes;
    }     public Classes getClasses1(int csId)
   {
       session =  HibernateSessionFactory.getSession();
       Query query = (Query) session.createQuery("from Classes as s where sno =  '"+csId+"'");
       Classes cl = (Classes) query.uniqueResult();
       HibernateSessionFactory.closeSession();
           return cl;
   }public void setCs(Classes cs) {
        this.cs = cs;
    }//这个是默认的DAO
麻烦各位了,是不是用了两个getclass函数的问题呢?
在学生的页面,用这种就可以:
<s:iterator value="classesList" id="row">
                <tr> 
                   <td><a href="choose!viewDetail.action?cid=<s:property value="#row.csId"/> "><s:property value="#row.cname" /></a>
                   </td><td>(<s:property value="#row.chooseCurNum"/> / <s:property value="#row.chooseMax" />)</td> 
                   </tr>
             </s:iterator>  
求解了

解决方案 »

  1.   

    恩是的
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package AdminAction;import com.opensymphony.xwork2.ActionSupport;
    import dao.ClassDao;
    import entity.Classes;/**
     *
     * @author mm
     */
    public class getCs extends ActionSupport{
           private int csId;
          private Classes cs;
       
          ClassDao c=new ClassDao();
        
        public getCs() {
        }
        
        @Override
        public String execute() throws Exception {
          if(c.getClasses(getCsId())!=null){
              setCs(c.getClasses1(getCsId()));
                return SUCCESS;
            }
            return INPUT;
        }    /**
         * @return the csId
         */
        public int getCsId() {
            return csId;
        }    /**
         * @param csId the csId to set
         */
        public void setCsId(int csId) {
            this.csId = csId;
        }    /**
         * @return the cs
         */
        public Classes getCs() {
            return cs;
        }    /**
         * @param cs the cs to set
         */
        public void setCs(Classes cs) {
            this.cs = cs;
        }
    }
      

  2.   

    恩是的
     /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */
     package AdminAction;
     
    import com.opensymphony.xwork2.ActionSupport;
     import dao.ClassDao;
     import entity.Classes;
     
    /**
      *
      * @author mm
      */
     public class getCs extends ActionSupport{
            private int csId;
           private Classes cs;
        
           ClassDao c=new ClassDao();
         
         public getCs() {
         }
         
         @Override
         public String execute() throws Exception {
           if(c.getClasses(getCsId())!=null){
               setCs(c.getClasses1(getCsId()));
                 return SUCCESS;
             }
             return INPUT;
         }
     
        /**
          * @return the csId
          */
         public int getCsId() {
             return csId;
         }
     
        /**
          * @param csId the csId to set
          */
         public void setCsId(int csId) {
             this.csId = csId;
         }
     
        /**
          * @return the cs
          */
         public Classes getCs() {
             return cs;
         }
     
        /**
          * @param cs the cs to set
          */
         public void setCs(Classes cs) {
             this.cs = cs;
         }
     }