铁手剑谱

上善若水
数据加载中……
《Struts in Action》中文修订版 第14章
最近忙于修订《Javaserver Faces in Action》,都没有时间来修改这个文档了。我发现校对文稿真的是一个非常辛苦的事情,比起写来,要麻烦得多。何况我又不是一个细致的人。真是有些痛苦。今天抽点时间来继续将这部分发点出来。

很多人都问,Struts中用什么处理模型和数据。

我以前总说,这和Struts有什么关系?
从实际上来说,这的确和他没什么关系,因为他是M中立的。你可以使用你自己喜欢的任何M实现。但是正因如此,其实也还是和她有关系的,那就是它本质上的MVC的分层设计。

对Struts本身来说,作为最成功的一个MVC框架,实际上其最成功之处和精彩之处就是其中的C,即它是一个比较好的Front Controller 模式的实现。 很多地方,特别是其它利用了它的大型框架,都利用了他的这个优点。比如Oracle 的ADF。

但是对小型应用来说,很多人在争论,Action到底是M还是C。其实这并不重要,如果应用小型,你尽管可以在其中实现你的Biz Logic。这样的话,它就是M。否则,稍大型一些的应用,最好还是作为一个C来使用,至少是C的一个helper。

那么,具体的M怎么办呢?常规的做法是委托给POJO或者EJB。但是基于分层的目的,这中间通常是需要一个缓冲,那就是Facade。SUN的 官方Facade实现原来推荐的是Session EJB,这感情好,如果你能搞定它,业务和实体也可以尽管使用EJB。如果你不能负担EJB之痛,你可以使用POJO Facade来访问你的POJO实现的逻辑。

那么你的POJO生长在哪里?目前的Spring 等IoC容器正是一个好地方。实际上我想将Spring 成为是“框架之框架”。
OK,那么数据层又如何?嘿嘿,实际上离Struts太远啦,严格说起来他不想知道,也不用知道。你可以使用任何需要的持久实现,关键是作为DTO传递给C和V的结果,以及它们之间的转换。

本书中的ProcessBean是早期的一个POJO Facade,非常不错。但是不知为和这个包一直在Apache Commons的沙坑中跳不出来。而且如今有些陈旧了。
不过,本章其中的RSS和Lucene的讲述倒是不错。值得参考。

这里下载

posted on 2005-08-17 17:24 铁手 阅读(1662) 评论(6)  编辑  收藏 所属分类: JavaStruts系列

评论

# re: 《Struts in Action》中文修订版 第14章 2005-08-17 18:21 CALM

Javaserver Faces in Action 什么时候可以看到呀?
  回复  更多评论    

# re: 《Struts in Action》中文修订版 第14章 2005-08-18 10:17 keith

对,希望Javaserver Faces in Action 快点出来。
其实也没有必要全部弄好再放上来,可以一章一章的放上来
支持!!!!!!!!
  回复  更多评论    

# re: 《Struts in Action》中文修订版 第14章 2005-08-18 16:40 happyrabbit

都说mvc把做可以把做页面和逻辑的人员分开,我觉得达不到啊.
反而增加了做页面的人员难度.要实现完全的分离还要些日子
  回复  更多评论    

# re: 《Struts in Action》中文修订版 第14章 2005-08-20 20:35 tom

Javaserver Faces in Action 是不是已经有孙勇的出版了?
  回复  更多评论    

# Struts in action is a 3.5 star book on Amazon.com,we got some better 2005-08-21 15:21 meji

I had been reading Struts in Action for quite a while,but finally i couldn't help diversing from it.

I read the English version and the Chinese version simultaneously,for 5 chapters,i suffered all the way since chapter 2.

The 1st chapter is quite straightforward on telling you what struts is,illustrating the struts is quite simple and easily understand.

But the following chapters are somehow too much detailed in literal arts,but only handful of code snippets were given to back the subjects.

Details sometimes are great but not for the beginners without detailed source code or real-live project. source snippets are just not bearly enough.


Considering,the book is too detailed to beginners,without complete srccode,hard to have an overall concept not mentioning learning struts.

the book is better for whom has familiar with struts at the 1st point and want some internal think of the struts.



  回复  更多评论    

# Suggesting "Struts:The Complete Reference" 2005-08-21 15:33 meji

after i realized the book is sucks to me,i decided to look for a better one...
Actually there's no 4+ stars book about STRUTS on the Amazon.com

but we have two 4 stars books that are better than the 3.5 one (Struts in action)
and well commented on that site.
namely Struts:
The Complete Reference" published by MH,

and

"Struts for dummies" by AW,

the latter one is written in American Slang,so if you only familiar with regular English please do not plunge in that.

While the former one here,is quite a good one and is well recieved too,only written in a good phrased English,which has straightforward illustrations of the Struts and with a consisten example from the begninning to the end,with the complete example you will easily understand how to make use of struts to gain an easy way on web development....

  回复  更多评论    

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


网站导航: