关键词:
传说中的100句背7000单词
传说中的100句背7000单词!
1. Typical of the grassland dwellers of the continent is the American antelope, or pronghorn.
1.美洲羚羊,或称叉角羚,是该大陆典型的草原动物。
2. Of the millions who saw Haley’s comet in 1986, how many people will live long enough to see it return in the twenty-first century.
2. 1986年看见哈雷慧星的千百万人当中,有多少人能够长寿到足以目睹它在二十一世纪的回归呢?
3. Anthropologists have discovered that fear, happiness, sadness, and surprise are universally reflected in facial expressions.
3.人类学家们已经发现,恐惧,快乐,悲伤和惊奇都会行之于色,这在全人类是共通的。
4. Because of its irritating effect on humans, the use of phenol as a general antiseptic has been largely discontinued.
4.由于苯酚对人体带有刺激性作用,它基本上已不再被当作常用的防腐剂了。
5. In group to remain in existence, a profit-making organization must, in the long run, produce something consumers consider useful or desirable.
5.任何盈利组织若要生存,最终都必须生产出消费者可用或需要的产品。
6. The greater the population there is in a locality, the greater the need there is for water, transportation, and disposal of refuse.
6.一个地方的人口越多,其对水,交通和垃圾处理的需求就会越大。
7. It is more difficult to write simply, directly, and effectively than to employ flowery but vague expressions that only obscure one’s meaning.
7.简明,直接,有力的写作难于花哨,含混而意义模糊的表达。
8. With modern offices becoming more mechanized, designers are attempting to personalize them with warmer, less severe interiors.
8.随着现代办公室的日益自动化,设计师们正试图利用较为温暖而不太严肃的内部装饰来使其具有亲切感。
9. The difference between libel and slander is that libel is printed while slander is spoken.
9.诽谤和流言的区别在于前者是书面的,而后者是口头的。
10. The knee is the joints where the thigh bone meets the large bone of the lower leg.
10.膝盖是大腿骨和小腿胫的连接处。
11. Acids are chemical compounds that, in water solution, have a sharp taste, a corrosive action on metals, and the ability to turn certain blue vegetable dyes red.
11.酸是一种化合物,它在溶于水时具有强烈的气味和对金属的腐蚀性,并且能够使某些蓝色植物染料变红。
12. Billie Holiday’s reputation as a great jazz-blues singer rests on her ability to give emotional depth to her songs.
12. Billie Holiday’s作为一个爵士布鲁斯乐杰出歌手的名声建立在能够赋予歌曲感情深度的能力。
13. Essentially, a theory is an abstract, symbolic representation of what is conceived to be reality.
13.理论在本质上是对认识了的现实的一种抽象和符号化的表达。
14. Long before children are able to speak or understand a language, they communicate through facial expressions and by making noises.
14.儿童在能说或能听懂语言之前,很久就会通过面部表情和靠发出噪声来与人交流了。
15. Thanks to modern irrigation, crops now grow abundantly in areas where once nothing but cacti and sagebrush could live.
15.受当代灌溉(技术设施)之赐,农作物在原来只有仙人掌和荞属科植物才能生存的地方旺盛的生长。
16. The development of mechanical timepieces spurred the search for more accurate sundials with which to regulate them.
16.机械计时器的发展促使人们寻求更精确的日晷,以便校准机械计时器。
17. Anthropology is a science in that anthropologists use a rigorous set of methods and techniques to document observations that can be checked by others.
17.人类学是一门科学,因为人类学家采用一整套强有力的方法和技术来记录观测结果,而这样记录下来的观测结果是供他人核查的。
18. Fungi are important in the process of decay, which returns ingredients to the soil, enhances soil fertility, and decomposes animal debris.
18.真菌在腐化过程中十分重要,而腐化过程将化学物质回馈于土壤,提高其肥力,并分解动物粪便。
19. When it is struck, a tuning fork produces an almost pure tone, retaining its pitch over a long period of time.
19.音叉被敲击时,产生几乎纯质的音调,其音量经久不衰。
20. Although pecans are most plentiful in the southeastern part of the United States, they are found as far north as Ohio and Illinois.
20.虽然美洲山河桃树最集中于美国的东南部但是在北至俄亥俄州及伊利诺州也能看见它们。
21. Eliminating problems by transferring the blame to others is often called scape-goating.
21.用怪罪别人的办法来解决问题通常被称为寻找替罪羊。
22. The chief foods eaten in any country depend largely on what grows best in its climate and soil.
22.一个国家的主要食物是什么,大体取决于什么作物在其天气和土壤条件下生长得最好。
23. Over a very large number of trials, the probability of an event’s occurring is equal to the probability that it will not occur.
23.在大量的实验中,某一事件发生的几率等于它不发生的几率。
24. Most substance contract when they freeze so that the density of a substance’s solid is higher than the density of its liquid.
24.大多数物质遇冷收缩,所以他们的密度在固态时高于液态。
25. The mechanism by which brain cells store memories is not clearly understood.
25.大脑细胞储存记忆的机理并不为人明白。
26. By the middle of the twentieth century, painters and sculptors in the United States had begun to exert a great worldwide influence over art.
26.到了二十一世纪中叶,美国画家和雕塑家开始在世界范围内对艺术产生重大影响。
27. In the eastern part of New Jersey lies the city of Elizabeth, a major shipping and manufacturing center.
27.伊丽莎白市,一个重要的航运和制造业中心,坐落于新泽西州的东部。
28. Elizabeth Blackwell, the first woman medical doctor in the United States, founded the New York Infirmary, an institution that has always had a completely female medical staff.
28. Elizabeth Blackwell,美国第一个女医生,创建了员工一直为女性纽约诊所。
29. Alexander Graham Bell once told his family that he would rather be remembered as a teacher of the deaf than as the inventor of the telephone.
29. Alexander Graham Bell曾告诉家人,他更愿意让后人记住他是聋子的老师,而非电话的发明者。
30. Because its leaves remain green long after being picked, rosemary became associated with the idea of remembrance.
30.采摘下的迷迭香树叶常绿不衰,因此人们把迷迭香树与怀念联系在一起。
31. Although apparently rigid, bones exhibit a degree of elasticity that enables the skeleton to withstand considerable impact.
31.骨头看起来是脆硬的,但它也有一定的弹性,使得骨骼能够承受相当的打击。
32. That xenon could not FORM chemical compounds was once believed by scientists.
32.科学家曾相信:氙气是不能形成化合物的。
33. Research into the dynamics of storms is directed toward improving the ability to predict these events and thus to minimize damage and avoid loss of life.
33.对风暴动力学的研究是为了提高风暴预测从而减少损失,避免人员伤亡。
34. The elimination of inflation would ensure that the amount of money used in repaying a loan would have the same value as the amount of money borrowed.
34.消除通货膨胀应确保还贷的钱应与所贷款的价值相同。
35. Futurism, an early twentieth-century movement in art, rejected all traditions and attempted to glorify contemporary life by emphasizing the machine and motion.
35.未来主义,二十世纪早期的一个艺术思潮。拒绝一切传统,试图通过强调机械和动态来美化生活。
36. One of the wildest and most inaccessible parts of the United States is the Everglades where wildlife is abundant and largely protected.
36. Everglades是美国境内最为荒凉和人迹罕至的地区之一,此处有大量的野生动植物而且大多受(法律)保护。
37. Lucretia Mott's influence was so significant that she has been credited by some authorities as the originator of feminism in the United States.
37. Lucretia Mott's的影响巨大,所以一些权威部门认定她为美国女权运动的创始人。
38. The activities of the international marketing researcher are frequently much broader than those of the domestic marketer.
38.国际市场研究者的活动范围常常较国内市场研究者广阔。
39. The continental divide refers to an imaginary line in the North American Rockies that divides the waters flowing into the Atlantic Ocean from those flowing into the Pacific.
39.大陆分水岭是指北美洛矶山脉上的一道想象线,该线把大西洋流域和太平洋流域区分开来。
40. Studies of the gravity field of the Earth indicate that its crust and mantle yield when unusual weight is placed on them.
40.对地球引力的研究表明,在不寻常的负荷之下地壳和地幔会发生位移。
41. The annual worth of Utah's manufacturing is greater than that of its mining and farming combined.
41.尤它州制造业的年产值大于其工业和农业的总和。
42. The wallflower is so called because its weak stems often grow on walls and along stony cliffs for support.
42.墙花之所以叫墙花,是因为其脆弱的枝干经常要靠墙壁或顺石崖生长,以便有所依附。
43. It is the interaction between people, rather than the events that occur in their lives, that is the main focus of social psychology.
43.社会心理学的主要焦点是人与人之间的交往,而不是他们各自生活中的事件。
44. No social crusade aroused Elizabeth Williams' enthusiasm more than the expansion of educational facilities for immigrants to the United States.
44.给美国的新移民增加教育设施比任何社会运动都更多的激发了Elizabeth Williams的热情。
45. Quails typically have short rounded wings that enable them to spring into full flight instantly when disturbed in their hiding places.
45.典型的鹌鹑都长有短而圆的翅膀,凭此他们可以在受惊时一跃而起,飞离它们的躲藏地。
46. According to anthropologists, the earliest ancestors of humans that stood upright resembled chimpanzees facially, with sloping foreheads and protruding brows.
46.根据人类学家的说法,直立行走的人的鼻祖面部轮廓与黑猩猩相似,额头后倾,眉毛突出。
47. Not until 1866 was the fully successful transatlantic cable finally laid.
47.直到1866年第一条横跨大西洋的电缆才完全成功的架通。
48. In his writing, John Crowe Ransom describes what he considers the spiritual barrenness of society brought about by science and technology.
48. John Crowe Ransom在他的著作中描述了他认为是由科学技术给社会带来的精神贫困。
49. Children with parents whose guidance is firm, consistent, and rational are inclined to possess high levels of self-confidence.
49.父母的教导如果坚定,始终如一和理性,孩子就有可能充满自信。
50. The ancient Hopewell people of North America probably cultivated corn and other crops, but hunting and gathering were still of critical importance in their economy.
50.北美远古的Hopewell人很可能种植了玉米和其他农作物,但打猎和采集对他们的经济贸易仍是至关重要的。
51. Using many symbols makes it possible to put a large amount of inFORMation on a single map.
51.使用多种多样的符号可以在一张地图里放进大量的信息。
52. Anarchism is a term describing a cluster of doctrines and attitudes whose principal uniting feature is the belief that government is both harmful and unnecessary.
52.无政府主义这个词描述的是一堆理论和态度,它们的主要共同点在于相信政府是有害的,没有必要的。
53. Probably no man had more effect on the daily lives of most people in the Untied States than did Henry Ford a pioneer in automobile production.
53.恐怕没有谁对大多数美国人的日常生活影响能超过汽车生产的先驱亨利.福特。
54. The use of well-chosen nonsense words makes possible the testing of many basic hypotheses in the field of language learning.
54.使用精心挑选的无意义词汇,可以检验语言学科里许多基本的假定。
55. The history of painting is a fascinating chain of events that probably began with the very first pictures ever made.
55.优化历史是由一连串的迷人事件组成,其源头大概可以上溯到最早的图画。
56. Perfectly matched pearls, strung into a necklace, bring a far higher price than the same pearls told individually.
56.相互般配的珍珠,串成一条项链,就能卖到比单独售出好得多的价钱。
57. During the eighteenth century, Little Turtle was chief of the Miami tribe whose territory became what is now Indiana and Ohio.
57.十八世纪时,"小乌龟"是迈阿密部落的酋长,该部落的地盘就是今天的印第安那州和俄亥俄州。
58. Among almost seven hundred species of bamboo, some are fully grown at less than a foot high, while others can grow three feet in twenty-four hours.
58.在竹子的近七百个品种中,有的全长成还不到一英尺,有的却能在二十四小时内长出三英尺。
59. Before staring on a sea voyage, prudent navigators learn the sea charts, study the sailing directions, and memorize lighthouse locations to prepare themselves for any conditions they might encounter.
59.谨慎的航海员在出航前,会研究航向,记录的灯塔的位置,以便对各种可能出现的情况做到有备无患。
60. Of all the economically important plants, palms have been the least studied.
60.在所有的经济作物中,棕榈树得到的研究最少。
61. Buyers and sellers should be aware of new developments in technology can and does affect marketing activities.
61.购买者和销售者都应该留意技术的新发展,原因很简单,因为技术能够并且已经影响着营销活动。
62. The application of electronic controls made possible by the microprocessor and computer storage have multiplied the uses of the modern typewriter.
62.电脑储存和由于电子微处理机得以实现的电控运用成倍的增加了现代打字机的功能。
63. The human skeleton consists of more than two hundred bones bound together by tough and relatively inelastic connective tissues called ligaments.
63.人类骨骼有二百多块骨头组成,住些骨头石油坚韧而相对缺乏弹性的,被称为韧带的结蒂组连在一起。
64. The pigmentation of a pearl is influenced by the type of oyster in which it develops and by the depth, temperature, and the salt content of the water in which the oyster lives.
64.珍珠的色泽受到作为其母体牡蛎种类及牡蛎生活水域的深度,温度和含盐度的制约。
65. Although mockingbirds superbly mimic the songs and calls of many birds, they can nonetheless be quickly identified as mockingbirds by certain aural clues.
65.尽管模仿鸟学很多种鸟的鸣叫声惟妙惟肖,但人类还是能够依其声音上的线索很快识别它们。
66. Not only can walking fish live out of water, but they can also travel short distances over land.
66.鲇鱼不仅可以离开水存活,还可以在岸上短距离移动。
67. Scientists do not know why dinosaurs became extinct, but some theories postulate that changers in geography, climate, and sea levels were responsible.
67.科学家不知道恐龙为何绝种了,但是一些理论推断是地理,气候和海平面的变化造成的。
68. The science of horticulture, in which the primary concerns are maximum yield and superior quality, utilizes inFORMation derived from other sciences.
68.主要目的在于丰富和优质的农艺学利用了其他科学的知识。
69. Snow aids farmers by keeping heart in the lower ground levels, thereby saving the seeds from freezing.
69.雪对农民是一种帮助,因为它保持地层土壤的温度,使种子不致冻死。
70. Even though the precise qualities of hero in literary words may vary over time, the basic exemplary function of the hero seems to remain constant.
70.历代文学作品中的英雄本色虽各有千秋,但其昭世功力却是恒古不变的。
71. People in prehistoric times created paints by grinding materials such as plants and clay into power and then adding water.
71.史前的人们制造颜料是将植物和泥土等原料磨成粉末,然后加水。
72. Often very annoying weeds, goldenrods crowd out less hardy plants and act as hosts to many insect pests.
72.黄菊花通常令人生厌,它挤走不那么顽强的植物,并找来很多害虫。
73. Starting around 7000 B.C., and for the next four thousand years, much of the Northern Hemisphere experienced temperatures warmer than at present.
73.大约从公元前七千年开始,在四千年当中,北半球的温度比现在高。
74. When Henry Ford first sought financial backing for making cars, the very notion of farmers and clerks owning automobiles was considered ridiculous.
74.当亨利.福特最初制造汽车为寻求资金支持时,农民和一般职员也能拥有汽车的想法被认为是可笑的。
75. Though once quite large, the population of the bald eagle across North America has drastically declined in the past forty years.
75.北美秃头鹰的数量一度很多,但在近四十年中全北美的秃头鹰数量急剧下降。
76. The beaver chews down trees to get food and material with which to build its home.
76.水獭啃倒树木,以便取食物并获得造窝的材料。
77. Poodles were once used as retrievers in duck hunting, but the American Kennel Club does not consider them sporting dogs because they are now primarily kept as pets.
77.长卷毛狗曾被用作猎鸭时叼回猎物的猎犬,但是美国Kennel Club却不承认它们为猎犬,因为它们现在大多数作为宠物饲养。
78. As a result of what is now know in physics and chemistry, scientists have been able to make important discoveries in biology and medicine.
78.物理学和化学的一个成果是使得科学家们能在生物学和医学上获得重大发现。
79. The practice of making excellent films based on rather obscure novels has been going on so long in the United States as to constitute a tradition.
79.根据默默无闻的小说制作优秀影片在美国由来已久,已经成为传统。
80. Since the consumer considers the best fruit to be that which is the most attractive, the grower must provide products that satisfy the discerning eye.
80.因为顾客认为最好的水果应该看起来也是最漂亮的,所以种植者必须提供能满足挑剔眼光的产品。
81. Television the most pervasive and persuasive of modern technologies, marked by rapid change and growth, is moving into a new era, an era of extraordinary sophistication and versatility, which promises to reshape our lives and our world.
81.电视,这项从迅速变化和成长为标志的最普及和最有影响力的现代技术,正在步入一个新时代,一个极为成熟和多样化的时代,这将重塑我们的生活和世界。
82. Television is more than just an electronics; it is a means of expression, as well as a vehicle for communication, and as such becomes a powerful tool for reaching other human beings.
82.电视不仅仅是一件电器;它是表达的手段和交流的载体并因此成为联系他人的有力工具。
83. Even more shocking is the fact that the number and rate of imprisonment have more than doubled over the past twenty years, and recidivism------that is the rate for re-arrest------is more than 60 percent.
83.更让人吃惊的事实是监禁的数目和比例在过去的二十年中翻了一番还有余,以及累犯率——即再次拘押的比例——为百分之六十强。
84. His teaching began at the Massachusetts Institute of Technology, but William Rainey Harper lured him to the new university of Chicago, where he remained officially for exactly a generation and where his students in advanced composition found him terrifyingly frigid in the classroom but sympathetic and understanding in their personal conferences.
84.他的教书生涯始于麻省理工学院,但是William Rainey Harper把他吸引到了新成立的芝加哥大学。他在那里正式任职长达整整一代人的时间。他的高级作文课上的学生觉得他在课上古板得可怕,但私下交流却富有同情和理解。
85. The sloth pays such little attention to its personal hygiene that green algae grow on its coarse hair and communities of a parasitic moth live in the depths of its coat producing caterpillars which graze on its mouldy hair. Its muscles are such that it is quits incapable of moving at a speed of over a kilometer an hour even over the shortest distances and the swiftest movement it can make is a sweep of its hooked arm.
85.树獭即不讲究卫生,以至于它粗糙的毛发上生出绿苔,成群的寄生蛾生长在它的皮毛深处,变成毛毛虫,并以它的脏毛为食。她的肌肉不能让他哪怕在很短的距离以内以每小时一公里的速度移动。它能做的最敏捷的动作就是挥一挥它弯曲的胳膊。
86. Artificial flowers are used for scientific as well as for decorative purposes. They are made from a variety of materials, such as way and glass, so skillfully that they can scarcely be distinguished from natural flowers.
86.人造花卉即可用于科学目的,也可用于装饰目的,它们可以用各种各样的材料制成,臂如蜡和玻璃;其制作如此精巧,几乎可以以假乱真。
87. Three years of research at an abandoned coal mine in Argonne, Illinois, have resulted in findings that scientists believe can help reclaim thousands of mine disposal sites that scar the coal-rich regions of the United States.
87.在伊利诺州Angonne市的一个废弃煤矿的三年研究取得了成果,科学家们相信这些成果可以帮助改造把美国产煤区弄得伤痕累累的数千个旧煤场。
88. When the persuading and the planning for the western railroads had finally been completed, the really challenging task remained: the dangerous, sweaty, backbreaking, brawling business of actually building the lines.
88.当有关西部铁路的说服和规划工作终于完成后,真正艰难的任务还没有开始;即危险,吃力,需要伤筋动骨和吵吵嚷嚷的建造这些铁路的实际工作。
89. Because of the space crunch, the Art Museum has become increasingly cautious in considering acquisitions and donations of art, in some cases passing up opportunities to strengthen is collections.
89.由于空间不足,艺术博物馆在考虑购买和接受捐赠的艺术品是越来越慎重,有些情况下放弃其进一步改善收藏的机会。
90. The United States Constitution requires that President be a natural-born citizen, thirty-five years of age or older, who has lived in the United States for a minimum of fourteen years.
90.美国宪法要求总统是生于美国本土的公民,三十五岁以上,并且在美国居住了至少十四年。
91. Arid regions in the southwestern United States have become increasingly inviting playgrounds for the growing number of recreation seekers who own vehicles such as motorcycles or powered trail bikes and indulge in hill-climbing contests or in caving new trails in the desert.
91.美国西部的不毛之地正成为玩耍的地方,对越来越多拥有摩托车或越野单车类车辆的,喜欢放纵于爬坡比赛或开辟新的沙漠通道的寻欢作乐者具有不断增长的吸引力。
92. Stone does decay, and so tools of long ago have remained when even the bones of the man who made them have disappeared without trace.
92.石头不会腐烂,所以以前的(石器)工具能保存下来,虽然它们的制造者已经消失的无影无踪。
93. Insects would make it impossible for us to live in the world; they would devour all our crops and kill our flocks and herds, if it were not for the protection we get from insect-eating animals.
93.昆虫就将会使我们无法在这个世界上居住;如果我们没有受到以昆虫为食的动物的保护,昆虫就会吞嚼掉我们所有的庄稼并杀死我们饲养的禽兽。
94. It is true that during their explorations they often faced difficulties and dangers of the most perilous nature, equipped in a manner which would make a modern climber shudder at the thought, but they did not go out of their way to court such excitement.
94.确实,他们在探险中遇到了极具威胁性的困难和危险,而他们的装备会让一个现代登山者想一想都会浑身颤栗。不过他们并不是刻意去追求刺激的。
95. There is only one difference between an old man and a young one: the young man has a glorious future before him and old one has a splendid future behind him: and maybe that is where the rub is.
95.老人和年轻人之间只有一个区别:年轻人的前面有辉煌的未来,老年人灿烂的未来却已在它们身后。这也许就是困难之所在。
96. I find young people exciting. They have an air of freedom, and they have not a dreary commitment to mean ambitions or love comfort. They are not anxious social climbers, and they have no devotion to material things.
96.我们位年强人振奋。它们带有自由的气息,他们不会为狭隘的野心和贪婪享受而孜孜以求。他们不是焦虑的向上爬的人,他们不会对物质性的东西难舍难分。
97. I am always amazed when I hear people saying that sport creates goodwill between the nations, and that if only the common peoples of the world could meet one another at football or cricket, they would have no inclination to meet on the battlefield.
97.每次我听说体育运动能够在国家间建立起友好感情,说世界各地的普通人只要能在足球场或板球场上相遇就会没有兴趣在战场上相遇的话,我都倍感诧异。
98. It is impossible to say simply for the fun and exercise: as soon as the question of prestige arises, as soon as you feel that you and some larger unit will be disgraced if you lose, the most savage combative instincts are around.
98.没有可能仅仅为了娱乐或锻炼而运动:一旦有了问题,一旦你觉得你输了你和你所属团体会有失体面时,你最野蛮的好斗本能就会被激发出来。
99. It has been found that certain bats emit squeaks and by receiving the echoes, they can locate and steer clear of obstacles------or locate flying insects on which they feed. This echo-location in bats is often compared with radar, the principle of which is similar.
99.人们已经发现,某些蝙蝠发出尖叫声并靠接受回响来锁定和避免障碍物——或者找到它们赖以为生的昆虫。蝙蝠这种回响定位法常拿来和原理与之很相近似的雷达相比。
100. As the time and cost of making a clip drop to a few days and a few hundred dollars, engineers may soon be free to let their imaginations soar without being penalized by expensive failure.
100.随着芯片制造时间和费用降低到了几天和几百美元,工程师们可能很快可以任他们的想象驰骋而不会被昂贵的失败所惩罚。
posted @
2006-08-16 20:25 阿成 阅读(259) |
评论 (0) |
编辑 收藏
摘要: 1. I see. 我明白了。2. I quit! 我不干了!3. Let go! 放手!4. Me too. 我也是。5. My god! 天哪!6. No way! 不行!7. Come on. 来吧(赶快)8. Hold on. 等一等。9. I agree。 我同意。10. Not bad. 还不错。11. Not yet. 还没。12. See you. 再见。13. Shut up! ...
阅读全文
posted @
2006-08-16 20:24 阿成 阅读(1530) |
评论 (0) |
编辑 收藏
概述
本手册包含conf/server.xml文件中所有配置指示符(directives)的参考信息,这些指示符决定了Tomcat 5的行为。本手册并不描述应该使用哪个配置指示符来完成特定的任务,请参考对应的HOW-TO文件。
配置元素的描述按照如下主目录来组织:
顶级元素-是整个配置文件的根元素,而代表与一个引擎(Engine)相关联的一组连接器(Connectors);
连接器(Connectors)-代表外部客户之间的接口。外部客户向特定的Service发送请求,并接收响应;
容器-代表一些组件。这些组件的功能是处理进来的请求,生成对应的响应。引擎(Engine)处理一个Service的所有请求,Host处理一个特定虚拟主机的所有请求。Context处理某个特定web应用的所有请求;
嵌入组件-代表可以嵌入容器的某个元素之中的元素。有些元素可以嵌入任何容器,而另一些元素只能嵌入在Context中。
对每个元素,对应的文档按照如下方式组织:
概述-对这个特定组件的整体描述。每个组件在org.apache.catalina包中存在一个对应的Java接口,可能有一个或多个标准实现实现了这个接口;
属性-该元素的合法属性。一般来说,这又分成公共属性和标准实现属性。公共属性是所有实现了该Java接口的实现都具有的属性。标准实现属性是实现了该Java接口的某个特定Java类具有的属性。必需的属性用粗体标出;
嵌套组件-列举了可以合法地嵌在这个元素下的组件;
专有特性-描述了该接口的标准实现支持的专有特性的配置,与每个元素类型有关;
顶级元素:Server Service
连接器:HTTP/1.1 JK
容器:Context Engine Host
嵌套组件:
Default Context
Global Resources
Loader
Logger
Manager
Realm
Resources
Valve
posted @
2006-08-16 20:03 阿成 阅读(254) |
评论 (0) |
编辑 收藏
Log4j基本使用方法
(转http://blogger.org.cn/blog/more.asp?name=dashee&id=6431)
Log4j由三个重要的组件构成:日志信息的优先级,日志信息的输出目的地,日志信息的输出格式。日志信息的优先级从高到低有ERROR、WARN、
INFO、DEBUG,分别用来指定这条日志信息的重要程度;日志信息的输出目的地指定了日志将打印到控制台还是文件中;而输出格式则控制了日志信息的显示内容。
一、定义配置文件
其实您也可以完全不使用配置文件,而是在代码中配置Log4j环境。但是,使用配置文件将使您的应用程序更加灵活。Log4j支持两种配置文件格式,一种是XML格式的文件,一种是Java特性文件(键=值)。下面我们介绍使用Java特性文件做为配置文件的方法:
1.配置根Logger,其语法为:
log4j.rootLogger
= [ level ] , appenderName, appenderName, …
其中,level
是日志记录的优先级,分为OFF、FATAL、ERROR、WARN、INFO、DEBUG、ALL或者您定义的级别。Log4j建议只使用四个级别,优先级从高到低分别是ERROR、WARN、INFO、DEBUG。通过在这里定义的级别,您可以控制到应用程序中相应级别的日志信息的开关。比如在这里定义了INFO级别,则应用程序中所有DEBUG级别的日志信息将不被打印出来。
appenderName就是指B日志信息输出到哪个地方。您可以同时指定多个输出目的地。
2.配置日志信息输出目的地Appender,其语法为:
log4j.appender.appenderName
=
fully.qualified.name.of.appender.class
log4j.appender.appenderName.option1
= value1
…
log4j.appender.appenderName.option =
valueN
其中,Log4j提供的appender有以下几种:
org.apache.log4j.ConsoleAppender(控制台),
org.apache.log4j.FileAppender(文件),
org.apache.log4j.DailyRollingFileAppender(每天产生一个日志文件),
org.apache.log4j.RollingFileAppender(文件大小到达指定尺寸的时候产生一个新的文件),
org.apache.log4j.WriterAppender(将日志信息以流格式发送到任意指定的地方)
3.配置日志信息的格式(布局),其语法为:
log4j.appender.appenderName.layout
=
fully.qualified.name.of.layout.class
log4j.appender.appenderName.layout.option1
= value1
…
log4j.appender.appenderName.layout.option =
valueN
其中,Log4j提供的layout有以e几种:
org.apache.log4j.HTMLLayout(以HTML表格形式布局),
org.apache.log4j.PatternLayout(可以灵活地指定布局模式),
org.apache.log4j.SimpleLayout(包含日志信息的级别和信息字符串),
org.apache.log4j.TTCCLayout(包含日志产生的时间、线程、类别等等信息)
Log4J采用类似C语言中的printf函数的打印格式格式化日志信息,打印参数如下:
%m 输出代码中指定的消息
%p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL
%r
输出自应用启动到输出该log信息耗费的毫秒数
%c 输出所属的类目,通常就是所在类的全名
%t 输出产生该日志事件的线程名
%n
输出一个回车换行符,Windows平台为“\r\n”,Unix平台为“\n”
%d
输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyy MMM dd
HH:mm:ss,SSS},输出类似:2002年10月18日 22:10:28,921
%l
输出日志事件的发生位置,包括类目名、发生的线程,以及在代码中的行数。举例:Testlog4.main(TestLog4.java:10)
二、在代码中使用Log4j
1.得到记录器
使用Log4j,第一步就是获取日志记录器,这个记录器将负责控制日志信息。其语法为:
public
static Logger getLogger( String
name)
通过指定的名字获得记录器,如果必要的话,则为这个名字创建一个新的记录器。Name一般取本类的名字,比如:
static
Logger logger = Logger.getLogger ( ServerWithLog4j.class.getName ()
)
2.读取配置文件
当获得了日志记录器之后,第二步将配置Log4j环境,其语法为:
BasicConfigurator.configure
(): 自动快速地使用缺省Log4j环境。
PropertyConfigurator.configure ( String
configFilename) :读取使用Java的特性文件编写的配置文件。
DOMConfigurator.configure ( String
filename )
:读取XML形式的配置文件。
3.插入记录信息(格式化日志信息)
当上两个必要步骤执行完毕,您就可以轻松地使用不同优先级别的日志记录语句插入到您想记录日志的任何地方,其语法如下:
Logger.debug
( Object message ) ;
Logger.info ( Object message ) ;
Logger.warn (
Object message ) ;
Logger.error ( Object message ) ;
posted @
2006-08-16 20:02 阿成 阅读(226) |
评论 (0) |
编辑 收藏
摘要: 本文介绍
Java
Web Framework
的基本工作原理,和一些常用的开源
Web
MVC Framework(Struts, Web Work, Tapestry, Echo, JSF, Maverick, Spring MVC,
Turbine, Cocoon, Barracuda)
。
...
阅读全文
posted @
2006-08-16 19:59 阿成 阅读(169) |
评论 (0) |
编辑 收藏
SPAN 和 DIV 的区别在于,DIV(division)是一个块级元素,可以包含段落、标题、表格,乃至诸如章节、摘要和备注等。而SPAN
是行内元素,SPAN 的前后是不会换行的,它没有结构的意义,纯粹是应用样式,当其他行内元素都不合适时,可以使用SPAN。
效果:
<span>SPAN标记有一个重要而实用的特性,即它什么事也不会做,它的唯一目的就是围绕你的HTML代码中的其它元素,这样你就可以为它们指定样式了。在此例中,<span>标识符允许你将一个段落分成不同的部分。
还有一个标识符具有类似的功能,<div>DIV也被用来在HTML文件中建立逻辑部分。但与<div>SPAN不同,<div>工作于文本块一级,它在它所包含的HTML元素的前面及后面都引入了行分隔。
posted @
2006-08-16 17:09 阿成 阅读(254) |
评论 (0) |
编辑 收藏
随着2005年Ajax这个名词的流行,关于Ajax技术本身的争论就一直喋喋不休。有些人为这种技术而激动,兴奋得投入到
Ajax的大潮中。有些人对Ajax大为诟病,认为其不过是一种炒作,其类似技术早已实现,毫无新意。也有些人还持一种观望的状态,等到大势所趋时,才进
行投入。
总之,一个新兴事物的诞生之初,有不同的观点进行争论是很正常的现象。作者作为支持Ajax的一派,对这个新生事物,可以说是倾注了很多精
力。从最初的不懂,到略知一二,再到深刻认识,发现Ajax背后隐藏的趋势,多少有些亢奋。凭此文,希望能够把自己的观点,表达一二。
Ajax在2005年异军突起,伴随着Web2.0,成为了本年度最为流行的名词之一。很多人看到这样一门技术,可能会很奇怪,感到很突兀。
- 为什么会突然产生这样一种技术?
- 类似的技术早就有,Ajax有什么突破?
- 为什么这种技术如此盛行,并被某些人认为是一种趋势呢?
如果你仅仅试图从Ajax本身去寻找这些问
题的答案,你可能会一无所获。如果你仅能够看到Ajax本身,那就如同瞎子摸象、管中窥豹,不能领略全局,当然也不能领会其意义。相反,如果你能够从一个
更好的高度上去思考Ajax所带来的好处,把Ajax放到一个相关的语境中去体会,你就会有另一番发现。
与Ajax相连的,还有这么两个名词—RiA和Web2.0。
什么是RiA?
RiA就是Rich Internet Application的缩写。
“Rich”代表功能强大,高交互性,高用户体验。
“Internet”代表方便。应用程序部署方便,用户使用方便。跨系统,跨语言。
其实RiA实际上一种基于Web的C/S架构(我称之为C/S/B)。由于有一个客户端,所以RiA应用可以提供强大的功能,让用户体验到高交互性,高
用户体验。同时,RiA又是基于Internet浏览器的应用,所以,用户使用RiA非常方便。理想来说,用户使用RiA应当像现在使用普通网页一样方
便。用户不需要安装任何的客户端软件,只要拥有浏览器。当用户通过浏览器发出指令,希望运行某种RiA应用程序时,一切都会飞快的建立在客户端机器上,就
像你在Web上点击一个页面一样。
目前,典型的RiA的代表有如下几种技术:
- MS ClickOnce
- Sun Java Web Start
- Adobe Flash
- Ajax
应该说,各大厂商均看到了RiA美好的未来,纷纷行动起来希望分一杯羹。只有Ajax技术在这些技术中有些特立独行。
Ajax并不属于任何厂商,相反,Ajax代表的是一种开源的风格。由于Ajax所采用的各种技术要么是基于标准的,要么也没有被各大厂商所垄断,所以
Ajax真正是一个平民化的技术,谁都可以用它。同时,由于Ajax采用的各种技术基于现有的浏览器,所以兼容性最好。用Ajax技术建立的网站,目前均
可以直接运行,不需要任何客户端的改变。
其他的各种技术与Ajax比较起来,目前或多或少的还有些兼容性的问题。虽然这些技术功能强
大,但是目前它们应用起来还并不是很方便。不过可以看到,随着时间的推进,相信,未来还是属于功能更强大的一方。除非Ajax本身的功能有所加强。这样,
就看Javascript的功力了。
RiA实际上代表的是一种回归。
最开始流行的C/S结构,因为功能强大,而且范围有限,不需要害怕部署问题。之后随着用户的增加,部署问题越来越大,导致B/S模式的产生。
B/S模式虽然功能有限,但是却使用非常方便。从长期来看,方便的作用还是非常巨大的。功能可以不断增强,但是如果不方便,将吓走所有的客户。实际上观
察一下Web的发展,就会发现,如今百花齐放的Web开发技术,其目的都是为了提高B/S架构的交互性,让他更能适应需要而已。
不过,
随着目前越来越多的应用需要一直到Web上,人们终于发现B/S模式的缺点。各种技术上的硬性问题均限制着B/S模式的发展。从最基本的请求/相应模型,
HTTP协议,到所有负载均运行在服务器上的事实,让我们迫切需要一种方式来提高Web的交互能力,但同时又不能丧失它的使用方便性。
于是,RiA诞生了。RiA就是基于浏览器的C/S结构。它将部分的服务器负载转移到客户端,同时又不会丧失使用和部署上的方便性。所以说,RiA就是一次回归,只不过这次回归我们没有原地不动,相反,我们找到了最佳结合点。如图1所示:
图1、RiA就是一种回归
但是,我们知道了RiA是一种回归。可是,为什么RiA会盛行呢?这就需要我们把RiA放到Web2.0的环境中去思考。
什么是Web2.0?
目前,对于Web2.0并没有明确的定义。在《What Is Web 2.0》这篇文章里,对Web2.0应用所需要具备的各种特点进行了总结,并且提了出来。
- Services, not packaged software, with cost-effective scalability
- Control over unique, hard-to-recreate data sources that get richer as more people use them
- Trusting users as co-developers
- Harnessing collective intelligence
- Leveraging the long tail through customer self-service
- Software above the level of a single device
- Lightweight user interfaces, development models, AND business models
虽然有这么多特性,但是Web2.0背后最本质的东西就只有两点:
- 软件向服务化发展,向平台化发展
- Web由原来“Publisher”的观点,发展成“Participation”的观点。
正是基于这两点,Web2.0时代迫切需要一种使用方便,高交互性的应用程序,而此重任,就落在了RiA身上。
通过图2,你可以看到由Web1.0到Web2.0的变化。
图2、Web1.0向Web2.0的演变
还是在《What Is Web 2.0》那篇文章里,勾勒出了一幅Web2.0的Meme
Map。这张图的中心代表的是Web2.0的核心概念,而旁边是Web2.0概念的延伸。在这张图里,我试图勾勒出一些迫切需要RiA的特征点。实际上,
你可以看到,在Web2.0的Meme Map里,到处充满了RiA的倩影。如图3所示:
图3、Web2.0中的RiA倩影
看看大象本身
介绍了这么多,让我们总结一下。
随着软件和互联网的发展,需求导致一种新的计算模型出现。这种计算模型的特色就是,软件逐渐的有前台推向后台,以平台的方式提供服务,让用户在前台表演。
计算模型的变化,导致Web2.0的出现。尽管仅仅是开始,但是,从Web2.0的身上你依然可以依稀看到这种变化的趋势。不过Web2.0要想有如此变化,要想让用户参与进来,就必须提供一个用户功能强大的,使用方便的用户接口(UI)。
于是,需求导致了RiA的出现。RiA提供了一个满足需求的用户接口,使得大家可以参与到Web2.0中来。但是,RiA要想应用起来,可能还需要一个过程。
于是,几种RiA技术中,目前使用起来最合适的Ajax凸现出来。正是由于Ajax出色的兼容性,让他走到了历史的前台。有了它,我们开始了一场新的革命。
图4显示了这些名词之间的关系。把它们放在一起看,也许你会发现不一样的东西。
图4、Ajax、RiA与Web2.0
未来的样子
当我走在北京的街头,我在想,如果我有一台智能手机,可以访问百度的map服务,也许我就不会像现在这样担心迷路了。实际上,类似的例子还有很多。如果Web2.0的明天已经到来,我们的生活会发生很多改变。
我不知道,尽管我很想知道。如果我真的能够看到未来的样子,再具备一些必要的执行力的话,也许我就是下一个比尔。不过,看到目前的这一点,已经令我非常兴奋。不管怎么样,我们都有权利想象。也有权利,用我们的手去改变世界。
怎么样?开始吧?Let’s do it!
posted @
2006-08-16 17:09 阿成 阅读(298) |
评论 (0) |
编辑 收藏
February 18, 2005
If
anything about current interaction design can be called “glamorous,”
it’s creating Web applications. After all, when was the last time you
heard someone rave about the interaction design of a product that
wasn’t on the Web? (Okay, besides the iPod.) All the cool, innovative
new projects are online.
Despite this, Web interaction
designers can’t help but feel a little envious of our colleagues who
create desktop software. Desktop applications have a richness and
responsiveness that has seemed out of reach on the Web. The same
simplicity that enabled the Web’s rapid proliferation also creates a
gap between the experiences we can provide and the experiences users
can get from a desktop application.
That gap is closing. Take a look at Google Suggest. Watch the way the suggested terms update as you type, almost instantly. Now look at Google Maps.
Zoom in. Use your cursor to grab the map and scroll around a bit.
Again, everything happens almost instantly, with no waiting for pages
to reload.
Google Suggest and Google Maps are two examples
of a new approach to web applications that we at Adaptive Path have
been calling Ajax. The name is shorthand for Asynchronous JavaScript +
XML, and it represents a fundamental shift in what’s possible on the
Web.
Defining Ajax
Ajax isn’t a technology.
It’s really several technologies, each flourishing in its own right,
coming together in powerful new ways. Ajax incorporates:
The
classic web application model works like this: Most user actions in the
interface trigger an HTTP request back to a web server. The server does
some processing — retrieving data, crunching numbers, talking to
various legacy systems — and then returns an HTML page to the client.
It’s a model adapted from the Web’s original use as a hypertext medium,
but as fans of The Elements of User Experience know, what makes the Web good for hypertext doesn’t necessarily make it good for software applications.
Figure 1: The traditional model for web applications (left) compared to the Ajax model (right).
This
approach makes a lot of technical sense, but it doesn’t make for a
great user experience. While the server is doing its thing, what’s the
user doing? That’s right, waiting. And at every step in a task, the
user waits some more.
Obviously, if we were designing the
Web from scratch for applications, we wouldn’t make users wait around.
Once an interface is loaded, why should the user interaction come to a
halt every time the application needs something from the server? In
fact, why should the user see the application go to the server at all?
How Ajax is Different
An
Ajax application eliminates the start-stop-start-stop nature of
interaction on the Web by introducing an intermediary — an Ajax engine
— between the user and the server. It seems like adding a layer to the
application would make it less responsive, but the opposite is true.
Instead
of loading a webpage, at the start of the session, the browser loads an
Ajax engine — written in JavaScript and usually tucked away in a hidden
frame. This engine is responsible for both rendering the interface the
user sees and communicating with the server on the user’s behalf. The
Ajax engine allows the user’s interaction with the application to
happen asynchronously — independent of communication with the server.
So the user is never staring at a blank browser window and an hourglass
icon, waiting around for the server to do something.
Figure
2: The synchronous interaction pattern of a traditional web application
(top) compared with the asynchronous pattern of an Ajax application
(bottom).
Every user action that normally would
generate an HTTP request takes the form of a JavaScript call to the
Ajax engine instead. Any response to a user action that doesn’t require
a trip back to the server — such as simple data validation, editing
data in memory, and even some navigation — the engine handles on its
own. If the engine needs something from the server in order to respond
— if it’s submitting data for processing, loading additional interface
code, or retrieving new data — the engine makes those requests
asynchronously, usually using XML, without stalling a user’s
interaction with the application.
Who’s Using Ajax
Google
is making a huge investment in developing the Ajax approach. All of the
major products Google has introduced over the last year — Orkut, Gmail, the latest beta version of Google Groups, Google Suggest, and Google Maps
— are Ajax applications. (For more on the technical nuts and bolts of
these Ajax implementations, check out these excellent analyses of Gmail, Google Suggest, and Google Maps.) Others are following suit: many of the features that people love in Flickr depend on Ajax, and Amazon’s A9.com search engine applies similar techniques.
These
projects demonstrate that Ajax is not only technically sound, but also
practical for real-world applications. This isn’t another technology
that only works in a laboratory. And Ajax applications can be any size,
from the very simple, single-function Google Suggest to the very
complex and sophisticated Google Maps.
At Adaptive Path,
we’ve been doing our own work with Ajax over the last several months,
and we’re realizing we’ve only scratched the surface of the rich
interaction and responsiveness that Ajax applications can provide. Ajax
is an important development for Web applications, and its importance is
only going to grow. And because there are so many developers out there
who already know how to use these technologies, we expect to see many
more organizations following Google’s lead in reaping the competitive
advantage Ajax provides.
Moving Forward
The
biggest challenges in creating Ajax applications are not technical. The
core Ajax technologies are mature, stable, and well understood.
Instead, the challenges are for the designers of these applications: to
forget what we think we know about the limitations of the Web, and
begin to imagine a wider, richer range of possibilities.
It’s going to be fun.
posted @
2006-08-16 17:08 阿成 阅读(233) |
评论 (0) |
编辑 收藏
1、表单验证,如何不提交就验证,是通过鼠标选中其他输入框表示前一个输入框输入完毕,就可以自动进行验证。
2、http://www.chinaren.com/ 大家都去过吧,首页顶部搜索条“学校、班机、同学、热贴、网页、音乐、图片”这些标签,点一个下面的内
容就换成与所点搜索项有关的,这是如何实现的呢?我要做这个功能
一.资源类网站
1,国内网站
1)Ajax中国(推荐)
一个专业的ajax技术网站,分类清晰,有大量的电子版教程,以及AJAX源码下载!
www.okajax.com
2)ajaxcn.org
李琨老师的blog。李琨:《ajax实战》译者.
www.ajaxcn.org
3)www.ajaxw3c.com
2,国外网站
1)、Ajax的诞生
Ajax:ANewApproachtoWebApplications
www.adaptivepath.com/publications/essays/archives/000385.php
2)、AJAXMatters
www.ajaxmatters.com
关于Ajax技术一个信息量非常大的网站,有点像Ajax世界中的TSS。
3)、AJAXPatterns
与AJAX设计模式相关的资源。
www.ajaxpatterns.org
www.softwareas.com/ajax-patterns
4)、http://www.ajaxian.com
二.热门文章
1.什么是AJAX
www.okajax.com/info/net/20060510.html
2.ajax技术简介
www.okajax.com/info/basic/200604654.html
3.ajax.net
www.okajax.com/info/basic/200604556.html
www.okajax.com/info/tech/200605589.html
weblogs.asp.net/mschwarz/archive/2005/04/11/399893.aspx(英文)
三.ajax相关下载(电子书教程/源码)
1.Ajax基础教程电子版
www.okajax.com/info/bookdown/200604950.htm
2.《AJAX实战》ajaxinaction电子版
www.okajax.com/info/bookdown/200604366.htm
3.AJAX开发简略
www.okajax.com/info/bookdown/20060538.htm
4.AJAX版CD管理系统(jsp)
www.okajax.com/info/codedown/200604327.htm
5.Alexa查询系统(Xmlhttp+Ajax)
www.okajax.com/info/codedown/200604982.htm
6.ASP.NET+AJAX解决网页打开等待问题
www.okajax.com/info/codedown/200604166.htm
7.Ajax技术简介(ajaxdemo)
www.okajax.com/info/codedown/200604576.htm
四.ajax相关图书
1.《Ajax实战》(目前Ajax领域最为全面深入的一本著作)
www.china-pub.com/computers/common/info.asp?id=28433
2.《Ajax基础教程》(亚马逊计算机榜首图书,国内第1本Ajax图书,中文pdf版)
http://www.devworld.cn/art2527.aspx
3.《Ajax修炼之道-Web2.0入门》(Ajax从小工到专家的首选图书)
www.china-pub.com/computers/common/info.asp?id=29430
4.《征服Ajax+Lucene构建搜索引擎》
www.china-pub.com/computers/common/info.asp?id=29996
5.《征服Ajax--Web2.0快速入门与项目实践(.net)》
www.china-pub.com/computers/common/info.asp?id=29995
6.《Ajax开发精要--概念、案例与框架》
www.china-pub.com/computers/common/info.asp?id=30006
7.AJAX——新手快车道
http://www.sp1.cn/ajax/info/bookdown/200605663.htm
8,Ajax 探密 (Ajax Hacks )
http://www.sp1.cn/ajax/info/bookdown/20060540.htm
9.Ajax基础教程电子版
http://wh.wlha.com.cn/bbs/pic/ajaxbasic.rar
五.部分技术文章
www.dragonson.com/doc/ajax.html
Ajax内部交流文档
info96.k12studio.com/~nio/comments.php?id=242_0_1_0_C
简单地对Ajax进行描述介绍
www.adaptivepath.com/publications/essays/archives/000385.php
Ajax:ANewApproachtoWebApplications
jibbering.com/2002/4/httprequest.html
UsingtheXMLHTTPRequestobject
developer.apple.com/internet/webcontent/xmlhttpreq.html
DynamicHTMLandXML:TheXMLHttpRequestObject
del.icio.us/popular/ajax
www.fiftyfoureleven.com/resources/programming/xmlhttprequest/examples
XMLHttpRequest&AjaxWorkingExamples
www.xml.com/lpt/a/2005/02/09/xml-http-request.html
VeryDynamicWebInterfaces
www.standards-schmandards.com/index.php?2005/03/01/16-ajax-and-accessibility
AJAXandAccessibility
www.xml.com/lpt/a/2005/05/11/ajax-error.html
ErrorsandAJAX
www.softwareas.com/ajax-patterns
AJAXPatterns:DesignPatternsforAJAXUsability
www.backbase.com/download/Whitepaper%20Backbase%20AJAX%20and%20Beyond.pdf
WhitepaperBackbaseAJAXandBeyond
www.ajaxpatterns.org/index.php?title=Main_Page
AJAXpatterns
www.onlamp.com/pub/a/onlamp/2005/05/19/xmlhttprequest.html
六、补充内容
在增加一个,有些基础教程,虽然不多,但是都蛮有用的!
http://www.sp1.cn/ajax/info/basic/index.htm
Ajax & XMLHttpRequset
http://tech.acnow.net/Html/Web/ASP/ASP_Skill/2006-6/15/163322869.shtml
了解Ajax框架
http://kb.csdn.net/java/Articles/200606/0964add7-c017-484e-9652-5d85030222c5.html
标题 实现无刷新闪烁二级联动下拉菜单
http://www.seaskyer.net/Index/Catalog11/266.html
标题 Ajax研究小结
http://www.seaskyer.net/Index/Catalog11/224.html
posted @
2006-08-16 17:08 阿成 阅读(285) |
评论 (0) |
编辑 收藏
首先了解一下什么时DWR(Direct Web Remoting )
DWR 是一个开放源码的使用 Apache 许可协议的解决方案,它包含服务器端 Java 库、一个 DWR servlet 以及
JavaScript 库。虽然 DWR 不是 Java 平台上唯一可用的 Ajax-RPC 工具包,但是它是最成熟的,而且提供了许多有用的功能。
从最简单的角度来说,DWR 是一个引擎,可以把服务器端 Java 对象的方法公开给 JavaScript 代码。使用 DWR
可以有效地从应用程序代码中把 Ajax 的全部请求-响应循环消除掉。这意味着客户端代码再也不需要直接处理 XMLHttpRequest
对象或者服务器的响应。不再需要编写对象的序列化代码或者使用第三方工具才能把对象变成 XML。甚至不再需要编写 servlet 代码把 Ajax 请求调整成对 Java 域对象的调用。
DWR 是作为 Web 应用程序中的 servlet 部署的。把它看作一个黑盒子,这个 servlet
有两个主要作用:首先,对于公开的每个类,DWR 动态地生成包含在 Web 页面中的 JavaScript。生成的 JavaScript
包含存根函数,代表 Java 类上的对应方法并在幕后执行 XMLHttpRequest
。
这些请求被发送给 DWR,这时它的第二个作用就是把请求翻译成服务器端 Java 对象上的方法调用并把方法的返回值放在 servlet
响应中发送回客户端,编码成 JavaScript。DWR 还提供了帮助执行常见的用户界面任务的 JavaScript 工具函数。
---------------------------------
概述
这篇文章阐述了使用开源项目DWR(直接Web远程控制)和AJAX(异步JavaScript和XML)的概念来提高Web应用的可用性。作者一步步来展示DWR如何使得AJAX的应用既简单又快捷。(1600字;2005年6月20日)
AJAX,
或者说是异步JavaScript和XML,描述了一种使用混合了HTML(或XHTML)和层叠样式表作为表达信息,来创建交互式的Web应用的开发技
术;文档对象模型(DOM),JavaScript,动态地显示和与表达信息进行交互;并且,XMLHttpRequest对象与Web服务器异步地交换
和处理数据。
因特网上许多例子展示了在一个HTML文件内部使用XMLHttpRequest与服务器端进行交互的必要的步骤。当手工地
编写和维护XMLHttpRequest代码时,开发者必须处理许多潜在的问题,特别是类似于跨浏览器的DOM实现的兼容性这样的问题。这将会导致在编码
和调试Javascript代码上面花费数不清的时间,这显然对开发者来说很不友好。
DWR(直接Web远程控制)项目是在Apache
许可下的一个开源的解决方案,它供给那些想要以一种简单的方式使用AJAX和XMLHttpRequest的开发者。它具有一套Javascript功能
集,它们把从HTML页面调用应用服务器上的Java对象的方法简化了。它操控不同类型的参数,并同时保持了HTML代码的可读性。
DWR
不是对一个设计的插入,也不强迫对象使用任何种类的继承结构。它和servlet框架内的应用配合的很好。对缺少DHTML编程经验的开发者来说,DWR
也提供了一个JavaScript库包含了经常使用的DHTML任务,如组装表,用item填充select下拉框,改变HTML元素的内容,如<
div>和<span>
DWR网站是详尽的并且有大量的文档,这也是这篇文章的基础。一些例子用来展示DWR如何使用和用它的库可以完成什么样的工作。
这篇文章让读者看到了一个使用了DWR的Web应用是如何一步步建立的。我会展示创建这个简单的示例应用的必要的细节,这个应用是可下载的并且可以在你的环境中布署来看看DWR如何工作。
注意:找到有关AJAX的信息并不困难;网页上有几篇文章和博客的条目涵盖了这个主题,每一个都试图指出和评论这个概念的不同的方面。在资源部分,你会找到一些有趣的指向示例和文章的链接,来学习AJAX的更多的内容。
示例应用
这篇文章使用的示例应用模拟了多伦多的一个公寓出租搜索引擎。用户可以在搜索前选择一组搜索标准。为了提高交互性,AJAX中以下两种情况下使用:
·应用通告用户配合他的选择会返回多少搜索结果。这个数字是实时更新的-使用AJAX-当用户选择的卧室和浴室的数量,或者价格范围变化时。当符合标准的搜索结果没有或太多时,用户就没有必要点击搜索按纽。
·数据库查询并取回结果是由AJAX完成的。当用户按下显示结果按钮时,数据库执行搜索。这样,应用看起来更具响应了,而整个页面不需要重载来显示结果。
数据库
我们使用的数据库是HSQL,它是一种占用资源很小的Java SQL数据库引擎,可以不需要安装和配置的与Web应用捆绑在一起。一个SQL文件被用来在Web应用的上下文启动时创建一个内存中的表并添加一些记录。
Java类
应
用包含了两个主要的类叫Apartment和ApartmentDAO。Apartment.java类是一个有着属性和getter/setter方法
的简单的Java类。ApartmentDAO.java是数据访问类,用来查询数据库并基于用户的搜索标准来返回信息。ApartmentDAO类的实
现的直接了当的;它直接使用了Java数据库联接调用来得到公寓的总数和符合用户请求的可用公寓的列表。
DWR配置和使用
设
置DWR的使用是简单的:将DWR的jar文件拷入Web应用的WEB-INF/lib目录中,在web.xml中增加一个servlet声明,并创建
DWR的配置文件。DWR的分发中需要使用一个单独的jar文件。你必须将DWR
servlet加到应用的WEB-INF/web.xml中布署描述段中去。
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<description>Direct Web Remoter Servlet</description>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
一
个可选的步骤是设置DWR为调试模式—象上面的例子那样—在servlet描述段中将debug参数设为true。当DWR在调试模式时,你可以从
HTMl网页中看到所有的可访问的Java对象。包含了可用对象列表的网页会出现在/WEBAPP/dwr这个url上,它显示了对象的公共方法。所列方
法可以从页面中调用,允许你,第一次,运行服务器上的对象的方法。下图显示了调试页的样子:
调试页
现
在你必须让DWR知道通过XMLHttpRequest对象,什么对象将会接收请求。这个任务由叫做dwr.xml的配置文件来完成。在配置文件中,定义
了DWR允许你从网页中调用的对象。从设计上讲,DWR允许访问所有公布类的公共方法,但在我们的例子中,我们只允许访问几个方法。下面是我们示例的配置
文件:
<dwr>
<allow>
<convert converter="bean" match="dwr.sample.Apartment"/>
<create creator="new" javascript="ApartmentDAO" class="dwr.sample.ApartmentDAO">
<include method="findApartments"/>
<include method="countApartments"/>
</create>
</allow>
</dwr>
上
面的文件实现了我们例子中的两个目标。首先,<convert>标记告诉DWR将dwr.sample.Apartment对象的类型转换为
联合数组,因为,出于安全的原因,DWR默认的不会转换普通bean。第二,<create>标记让DWR暴露出
dwr.sample.ApartmentDAO类给JavaScript调用;我们在页面中使用JavaScript文件被javascript属性定
义。我们必须注意<include>标记,它指明了dwr.sample.ApartmentDAO类的哪些方法可用。
HTML/JSP代码
配
置完成后,你就可以启动你的Web应用了,这时DWR会为从你的HTML或Java服务器端页面(JSP)上调用所需方法作好准备,并不需要你创建
JavaScript文件。在search.jsp文件中,
我们必须增加由DWR提供的JavaScript接口,还有DWR引擎,加入以下三行到我们的代码中:
<script src='dwr/interface/ApartmentDAO.js'></script>
<script src='dwr/engine.js'></script>
<script src='dwr/util.js'></script>
我
们注意到当用户改变搜索标准时,这是AJAX在示例程序中的首次应用;正如他所看到的,当标准改变时,可用的公寓数量被更新了。我创建了两个
JavaScript函数:当某一个选择下拉框中的值变化时被调用。ApartmentDAO.countApartments()函数是最重要的部分。
最有趣的是第一个参数,
loadTotal()函数,它指明了当接收到服务端的返回时DWR将会调用的JavaScript方法。loadTotal于是被调用来在HTML页面
的<div>中显示结果。下面是在这个交互场景中所使用到的JavaScript函数:
function updateTotal() {
$("resultTable").style.display = 'none';
var bedrooms = document.getElementById("bedrooms").value;
var bathrooms = document.getElementById("bathrooms").value;
var price = document.getElementById("price").value;
ApartmentDAO.countApartments(loadTotal, bedrooms, bathrooms, price);
}
function loadTotal(data) {
document.getElementById("totalRecords").innerHTML = data;
}
很明显,用户想看到符合他的搜索条件的公寓列表。那么,当用户对他的搜索标准感到满意,并且总数也是有效的话,他会按下显示结果的按纽,这将会调用updateResults() JavaScript方法:
function updateResults() {
DWRUtil.removeAllRows("apartmentsbody");
var bedrooms = document.getElementById("bedrooms").value;
var bathrooms = document.getElementById("bathrooms").value;
var price = document.getElementById("price").value;
ApartmentDAO.findApartments(fillTable, bedrooms, bathrooms, price);
$("resultTable").style.display = '';
}
function fillTable(apartment) {
DWRUtil.addRows("apartmentsbody", apartment, [ getId, getAddress, getBedrooms, getBathrooms, getPrice ]);
}
updateResults
()方法清空了存放搜索返回结果的表域,从用户界面上获取所需参数,并且将这些参数传给DWR创建的ApartmentDAO对象。然后数据库查询将被执
行,fillTable()将会被调用,它解析了DWR返回的对象(apartment),然后将其显示到页面中(apartmentsbody)。
安全因素为
了保持示例的简要,ApartmentDAO类尽可能的保持简单,但这样的一个类通常有一组设置方法来操作数据,如insert(),
update()和delete()。DWR暴露了所有公共方法给所有的HTML页面调用。出于安全的原因,像这样暴露你的数据访问层是不明智的。开发者
可以创建一个门面来集中所有JavaScript函数与底层业务组件之间的通信,这样就限制了过多暴露的功能。
结论这
篇文章仅仅让你在你的项目中使用由DWR支持的AJAX开了个头。DWR让你集中注意力在如何提高你的应用的交互模型上面,消除了编写和调试
JavaScript代码的负担。使用AJAX最有趣的挑战是定义在哪里和如何提高可用性。DWR负责了操作Web页面与你的Java对象之间的通信,这
样就帮助你完全集中注意力在如何让你的应用的用户界面更加友好,
我想感谢Mircea Oancea和Marcos Pereira,他们阅读了这篇文章并给予了非常有价值的返匮。
资源·javaworld.com:
javaworld.com·Matrix-Java开发者社区:
http://www.matrix.org.cn/·onjava.com:
onjava.com·下载示例程序的全部源码:
http://www.javaworld.com/javaworld/jw-06-2005/dwr/jw-0620-dwr.war·DWR: http://www.getahead.ltd.uk/dwr/index.html
·HSQL:http://hsqldb.sourceforge.net/
·AJAX的定义:http://en.wikipedia.org/wiki/AJAX
·
“AJAX:通向Web应用的新途径": Jesse James Garrett (Adaptive Path, 2005.2):
http://www.adaptivepath.com/publications/essays/archives/000385.php
· “非常动态的Web界面” Drew McLellan (xml.com, 2005.2): http://www.xml.com/pub/a/2005/02/09/xml-http-request.html
·XMLHttpRequest & AJAX 工作范例: http://www.fiftyfoureleven.com/resources/programming/xmlhttprequest/examples
· “可用的XMLHttpRequest实践” Thomas Baekdal (Baekdal.com, 2005.3): http://www.baekdal.com/articles/Usability/usable-XMLHttpRequest/
·"XMLHttpRequest
使用导引" Thomas Baekdal
(Baekdal.com, 2005.2):http://www.baekdal.com/articles/Usability/XMLHttpRequest-guidelines/
·AJAX实质:http://www.ajaxmatters.com/
posted @
2006-08-16 17:06 阿成 阅读(280) |
评论 (0) |
编辑 收藏