waysun一路阳光

不轻易服输,不轻言放弃.--心是梦的舞台,心有多大,舞台有多大。踏踏实实做事,认认真真做人。

  BlogJava :: 首页 :: 新随笔 :: 联系 ::  :: 管理 ::
  167 随笔 :: 1 文章 :: 64 评论 :: 0 Trackbacks
1.首先是一个页面的调用
<html:form action="softevaluate/scoreSet" method="POST">
<html:link action="softevaluate/scoreSet.do?do=setScore" paramName="Info" paramProperty="scoreId" paramId="scoreId">
</html:form>
2.Action事件响应
public class ScoreSetAction extends DispatchAction
{
       
/****************************************************************/
/****打分参数设置 添加 2008-04-11 14:59***/
 public ActionForward setScore(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
   throws Exception {
  /******************************************************************/
  /**添加 从数据库获得参数,去掉最高分,去掉最低分*/
    String maxscore = "";
    String minscore = "";   
    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    org.hibernate.classic.Session session = sessionFactory.openSession();
    Query query =session.createQuery("from ScoreViable");
    List users=query.list();
    session.close();
    sessionFactory.close();
    for (ListIterator iterator = users.listIterator(); iterator.hasNext(); )
    {
     ScoreViable user = (ScoreViable) iterator.next();
     //System.out.println(user.getBeforCount() +"Age: " + user.getEndCount()+"///");
     maxscore=user.getBeforCount()+"";
     minscore=user.getEndCount()+"";
    }
    String []st=new String[2];
    st[0]=maxscore;
    st[1]=minscore;
/****为bean   ScoreViable 赋值**********/
    ScoreViable scoreViable=new ScoreViable();
    scoreViable.setBeforCount(new Long(maxscore));
    scoreViable.setEndCount(new Long(minscore));
    request.setAttribute("scoreViable", scoreViable);

  /***********************************************************************************/
  return mapping.findForward("setScore");
 }
}

3.在另外的的页面使用bean
  <logic:present name="scoreViable" scope="request"> 
  <tr>
    <td width="200" class=content><div align="right">去掉最高分个数:</div></td> 
    <bean:define id="beforCount" name='scoreViable' property='beforCount' /> 
    <td width="200" class=content><input type="text" name="maxscore" value="<%=beforCount%>"/></td>
    <td width="200" class=content></td>
    <td width="200" class=content></td>
  </tr>
  <tr>
    <td width="200" class=content><div align="right">去掉最低分个数:</div></td>
    <bean:define id="endCount" name='scoreViable' property='endCount' />
    <td width="200" class=content><input type="text" name="minscore" value="<%=endCount%>"/></td>
    <td width="200" class=content></td>
    <td width="200" class=content></td>
  </tr>
  </logic:present>
4.ScoreViable.
java  JAVA BEAN

ublic class ScoreViable implements java.io.Serializable {

    // Fields   
     private Long id;
     private Long beforCount;
     private Long endCount;
 
    // Constructors
    /** default constructor */
    public ScoreViable() {
    }
 /** minimal constructor */
    public ScoreViable(Long id, Long beforCount, Long endCount) {
        this.id = id;
        this.beforCount = beforCount;
        this.endCount = endCount;
    }
   
    /** full constructor */

  
    // Property accessors
    public Long getId() {
        return this.id;
    }
   
    public void setId(Long id) {
        this.id = id;
    }
    public Long getBeforCount() {
        return this.beforCount;
    }
   
    public void setBeforCount(Long beforCount) {
        this.beforCount = beforCount;
    }
    public Long getEndCount() {
        return this.endCount;
    }
   
    public void setEndCount(Long endCount) {
        this.endCount = endCount;
    }
}

5.struts-config.xml
  <action attribute="scoreSetForm" name="scoreSetForm"
   parameter="do" path="/softevaluate/scoreSet" scope="request"
   type="com.gpdi.softevaluate.action.ScoreSetAction">
   <forward name="list" path="/softevaluate/scoreSetList.jsp" />
   <forward name="scorelist" path="/softevaluate/scoreList.jsp" />   
   <forward name="add" path="/softevaluate/scoreSetPropertyManage.jsp" /> 
   <forward name="edit" path="/softevaluate/scoreSetPropertyManage.jsp" />
   <forward name="saveAdd" path="/softevaluate/scoreSet.do?do=list" /> 
   <forward name="setScore" path="/softevaluate/scoreCountSet.jsp" /> 
   <forward name="importScore" path="/softevaluate/scoreCountSet.jsp" /> 
      <forward name="DelList"
    path="/softevaluate/scoreSet.do?do=list" /> 
  
</action> 
posted on 2008-06-20 08:39 weesun一米阳光 阅读(176) 评论(0)  编辑  收藏 所属分类: 总结备用

只有注册用户登录后才能发表评论。


网站导航: