隨筆-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 還是孤立的  回復  更多評論
            

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


          網站導航:
           
          主站蜘蛛池模板: 清水县| 全南县| 石屏县| 元江| 香格里拉县| 山阴县| 肇州县| 陆川县| 进贤县| 安龙县| 平和县| 武夷山市| 府谷县| 文水县| 中山市| 建水县| 道真| 台东市| 慈溪市| 大宁县| 元氏县| 深泽县| 潼关县| 贵州省| 天水市| 宜良县| 普格县| 荥阳市| 原平市| 社会| 通海县| 邛崃市| 武穴市| 阜新| 新建县| 广汉市| 南和县| 郎溪县| 乐至县| 元阳县| 酉阳|