随笔-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 怡众科技 阅读(1976) 评论(1)  编辑  收藏 所属分类: 原创区

评论:
# re: 建立一个Struts2+ibatis应用程序(一) 2008-05-19 11:06 | 隔叶黄莺
这种用法其实 struts2 和 ibatis 还是孤立的  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: