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

          1、簡介

          ????????????簡單的頁面輸入并顯示的功能,有兩個頁面,
          ????????????upnews.jsp 提供輸入內(nèi)容的界面,show.jsp顯示已經(jīng)輸入的內(nèi)容

          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、在鏈接時候,沒有加“/”導(dǎo)致不能正常連接
          2、forward?name="suc"?path="/show.jsp"?redirect="true"?起初沒有加redirect,不能跳轉(zhuǎn)。
          posted on 2006-10-27 12:39 rkind 閱讀(485) 評論(0)  編輯  收藏 所屬分類: Struts
          主站蜘蛛池模板: 武山县| 南陵县| 庐江县| 杭锦后旗| 银川市| 四平市| 云和县| 新巴尔虎左旗| 台中市| 汉寿县| 徐汇区| 万年县| 内丘县| 璧山县| 姜堰市| 湟中县| 蕲春县| 日喀则市| 调兵山市| 东方市| 和林格尔县| 长宁县| 天水市| 盐山县| 土默特右旗| 泰安市| 江永县| 云南省| 康马县| 彰化市| 二手房| 安平县| 依安县| 巢湖市| 徐州市| 奇台县| 天全县| 临安市| 错那县| 福建省| 高陵县|