jinfeng_wang

G-G-S,D-D-U!

BlogJava 首页 新随笔 联系 聚合 管理
  400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks

 

 

整个Web应用分为四部分

1、  单独的DAO,负责数据访问,执行CUID(create, update, insert ,delete)完成O/R映射。不涉及任何的其他逻辑,仅执行这以上的操作,如果有唯一性检查、事务也不需要做。(可以在数据库端加一些trigger,constraint)。该层需要定义DAO接口,DAO实现(hibernateibaitsJDBC)

2、  简单的Logic ObjectJava Bean),data field+setter+getter+Other Logic,可以将一些共有的操作提取到父类中,减少代码。

3、  Business Sevice,实现业务逻辑,在此使用DAOLogic Object完成业务操作。这里当使用到DAO时,只需要IOC注入,真实对象由外界(Web容器调用Spring容器)注入。

4、  编写Action,将用户界面的操作映射到Busibess service

 

使用Spring MVC的具体配置:

1、web.xml, 增加dispatcher的定义,配置好URL Mapping分发用户调用。

        <servlet>

           <servlet-name>action</servlet-name>

        <servlet-class>

org.springframework.web.servlet.DispatcherServlet

</servlet-class>

        <load-on-startup>1</load-on-startup>

        </servlet>

 

    <servlet-mapping>

            <servlet-name>action</servlet-name>

            <url-pattern>*.html</url-pattern>

    </servlet-mapping>

编写相应的action-servlet.xml

 

 

2、如果使用了多个context文件(Spring的配置文件),则需要在Web.xml中进行配置,具体如下:

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>

/WEB-INF/applicationContext1.xml

/WEB-INF/applicationContext2.xml

</param-value>

</context-param>

   其位置在“sitemesh filter”之后,但是在filter-mapping之前。

 

3. 增加ContextLoaderListener.

       <listener>

          <listener-class>

org.springframework.web.context.ContextLoaderListener

</listener-class>

  </listener>

 

对照了Spring in action,那个讲的更好哦。从spring的基础开始讲起,很不错。

posted on 2005-03-01 17:39 jinfeng_wang 阅读(1715) 评论(2)  编辑  收藏 所属分类: spring

评论

# re: Sping Live笔记一 2006-04-23 17:54 5
56455555555555555555566666666666
666666666666666666
2222222222222222222222222
11111111111
33333333333333333333333333333

22222222222222222222222222
33333333333333333333333333333333333333333333
  回复  更多评论
  

# re: Sping Live笔记一 2006-08-23 02:18 sping
i made the same typo and found u.   回复  更多评论
  


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


网站导航: