雅典之夏的小站
          知人者智 自知者明 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
          主站蜘蛛池模板: 桐梓县| 永胜县| 合阳县| 武乡县| 娄底市| 正定县| 黔南| 五大连池市| 竹山县| 宁强县| 弥勒县| 湖口县| 安庆市| 新源县| 武威市| 江西省| 银川市| 兰考县| 五大连池市| 扶余县| 大埔县| 定州市| 获嘉县| 万盛区| 鹤岗市| 泰安市| 自治县| 边坝县| 松桃| 彰化市| 哈巴河县| 新乐市| 嘉善县| 普陀区| 沽源县| 连山| 来宾市| 江都市| 商洛市| 绿春县| 龙口市|