隨筆-8  評論-4  文章-0  trackbacks-0

           
          (1)部署lib庫中文件Struts+ibatis,共6個。
          (2)配置struts2中的web.xml,目的是讓Struts2來解釋web應用。內容如下:
             <?xml version="1.0" encoding="UTF-8"?>
          <web-app version="2.4"
           xmlns="http://java.sun.com/xml/ns/j2ee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
           http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
           <filter> <!--定義filter名稱,制定filter使用的類 -->
                   <filter-name>struts2</filter-name>
                   <filter-class>
                             org.apache.struts2.dispatcher.FilterDispatcher
                   </filter-class>
           </filter>
           <filter-mapping>
                   <filter-name>struts2</filter-name>
                   <url-pattern>/*</url-pattern><!--定義filtemapping指定搜索路徑為根路徑開始-->
           </filter-mapping>
            <welcome-file-list>
              <welcome-file>index.jsp</welcome-file>
            </welcome-file-list>
          </web-app>


          (3)配置Struts2的Struts.xml文件,目的是建立struts2中邏輯調用機制。-----------------------改
          內容如下:===============================需要修改
          <?xml version="1.0" encoding="UTF-8" ?>
          <!DOCTYPE struts PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
              "http://struts.apache.org/dtds/struts-2.0.dtd">
          <struts>
             <package name="yzth" namespace="/" extends="struts-default">
            <action name="hello" class="org.lxh.struts2.demo.HelloAction">
             <result name="success">
              /hello.jsp
             </result>
             <result name="error">
              /error.jsp
             </result>
            </action>
           </package>
          </struts>
          (4)配置Ibatis中的各個關鍵環節
            POJO類的建立      *** 用于存儲ORMapping映射后的數據記錄,只包含get 和set 方法
            com.mydomain.jata中的
            Account.xml       *** 最重要的ORMapping文件,存儲了對數據訪問的各種映射的SQL操作。
            SqlMapConfig.xml  *** 存儲連接數據的方法,配置數據連接池。
          (5)設計調用界面
              
               index.jsp==>hello.action==>account.class(應該從hello.action中調用ormapping)==>struts.xml==>hello.jsp

          (5.1)index.jsp使用S:標記傳值給hello.action

          <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
          <form action="hello.action" method="post">
              根據ID進行查詢:<input type="text" name="msg">
              <input type="submit" value="提交">
          </form>

          (5.2)hello.action使用Msg接收id后,調用account進行查詢。
          ===========================================================================
          這個過程沒搞清楚,準備找1個struts2+ibatis的開源項目研究一下再繼續。。。。


          posted on 2007-12-03 21:09 怡眾科技 閱讀(1988) 評論(1)  編輯  收藏 所屬分類: 原創區

          評論:
          # re: 建立一個Struts2+ibatis應用程序(一) 2008-05-19 11:06 | 隔葉黃鶯
          這種用法其實 struts2 和 ibatis 還是孤立的  回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 象山县| 上高县| 常州市| 林芝县| 江安县| 濮阳县| 扎赉特旗| 红原县| 政和县| 正阳县| 河池市| 册亨县| 达州市| 兴义市| 绵阳市| 修文县| 平湖市| 南涧| 共和县| 曲靖市| 望奎县| 平定县| 水富县| 马鞍山市| 额敏县| 湖北省| 丹东市| 泾川县| 婺源县| 积石山| 会昌县| 仁怀市| 司法| 沁阳市| 仁寿县| 潼关县| 玉屏| 敖汉旗| 浮山县| 朝阳市| 涿鹿县|