雅典之夏的小站
          知人者智 自知者明 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
          主站蜘蛛池模板: 盱眙县| 肇庆市| 冀州市| 桐城市| 开封市| 伽师县| 香格里拉县| 涞源县| 平原县| 兴山县| 秭归县| 龙里县| 香格里拉县| 庆阳市| 平利县| 格尔木市| 平陆县| 澜沧| 桃园市| 鹤庆县| 抚州市| 阿勒泰市| 黄龙县| 汤阴县| 贵南县| 中卫市| 上杭县| 乌苏市| 大田县| 清徐县| 双峰县| 横山县| 秦皇岛市| 金门县| 新蔡县| 黎平县| 苍溪县| 宾川县| 开江县| 小金县| 合山市|