雅典之夏的小站
          知人者智 自知者明 Fighting!!

          1、簡介

          ????????????簡單的頁面輸入并顯示的功能,有兩個頁面,
          ????????????upnews.jsp 提供輸入內容的界面,show.jsp顯示已經輸入的內容

          2、源碼
          ??????struts-config,流程圖

          Snap3.jpg
          源代碼
          Strust-config.xml

          <form-bean?name="upNewsForm"?type="com.rkind.struts.form.UpNewsForm"?/>
          ????????<action?attribute="upNewsForm"?input="/upNews.jsp"?name="upNewsForm"?path="/upNews"?scope="request"?type="com.rkind.struts.action.UpNewsAction">
          ????????????
          <forward?name="suc"?path="/show.jsp"?redirect="true"?/>
          ????????
          </action>


          upnews.jsp
          ???? 都是eclispe自動生成的
          <html:form?action="/upNews">
          ????????????content?:?
          <html:text?property="content"/><html:errors?property="content"/><br/>
          ????????????
          <html:submit/><html:cancel/>
          ????????
          </html:form>

          show.jsp這個簡單就一句話,
          <bean:write?name="upNewsForm"?property="content"/>

          模型的部分 formbean,自動生成,未做改動
          Controller部分,核心啊
          UpNewsForm?upNewsForm?=?(UpNewsForm)?form;
          ????????
          //?TODO?Auto-generated?method?stub
          ????????String?te=upNewsForm.getContent();
          ????????
          try{
          ????????
          if(te.equals("")){
          ????????????
          return?new?ActionForward(mapping.getInput());????????
          ????????}

          ????????
          return?(mapping.findForward("suc"));
          ????????}
          catch(Exception?e){
          ????????????
          throw?new?RuntimeException(e.getMessage());

          好了,但是在測試的時候一直出問題,輸入以后不能正常,原因有2
          1、在鏈接時候,沒有加“/”導致不能正常連接
          2、forward?name="suc"?path="/show.jsp"?redirect="true"?起初沒有加redirect,不能跳轉。
          posted on 2006-10-27 12:39 rkind 閱讀(496) 評論(0)  編輯  收藏 所屬分類: Struts
          主站蜘蛛池模板: 达拉特旗| 修文县| 射阳县| 资中县| 崇州市| 京山县| 固阳县| 策勒县| 淮南市| 郑州市| 虞城县| 纳雍县| 育儿| 铁岭县| 马鞍山市| 安远县| 青州市| 安泽县| 叶城县| 扎囊县| 安乡县| 交口县| 镇坪县| 遂川县| 明溪县| 剑阁县| 长丰县| 丰都县| 高碑店市| 延安市| 望奎县| 东源县| 安新县| 奉节县| 葵青区| 奇台县| 通州区| 游戏| 东至县| 平和县| 株洲县|