外文资料翻译---struts和tiles辅助基于组件的开发(编辑修改稿)内容摘要:

us highly patible with all J2EE application servers. Malcolm Davis39。 s developerWorks article on Struts covers functionality through Struts。 for brevity39。 s sake, I will discuss only changes and Struts topics that he didn39。 t cover. The current release version of Struts is , but there is a beta version, labeled , that has been available since March 19, 2020. Because the beta version represents a code freeze in which only bug fixes are being worked on, there is an extremely good chance that the final version of will be out shortly, a sentiment that has been echoed on the Struts mailing lists. Therefore, any new projects making use of Struts should probably begin on the code base, and that is what I will cover. Useful additions to the Struts framework since version include improved form validation functionality, the ability to specify form elements via XML declarations, and the ability to dynamically define bean properties. Probably the most prominent addition, however, has been the incorporation of the Tiles templating library into the Struts distribution. Have you ever wanted an easier way to create a set of pages (or perhaps a whole application) with a consistent user interface the same navigation bar, header, footer, and so on on every page? What about a way to display portletlike rectangles of content within a larger page of content? The Tiles framework lets you acplish both tasks and more. Through a central XML file defining screens and a set of tags that can be embedded in JSP pages to insert static and dynamic content, the Tiles framework allows you to build ponentized views and assemble them as you like, thus aiding flexibility, reusability, consistency, and maintainability. Struts and Tiles interact well because the developers of the two projects have recognized their plementary nature and decided to cooperate. A developer can specify a Tiles page definition as the target view (a forward in Struts parlance) of a Struts action. Because both Struts and Tiles conform to the JSP tag library specifications, Struts tags and Tiles tags can be intermixed in JSP pages. You are likely itching to try out the Tiles framework and see exactly what it can do. Struts and Tiles are aids for Web development, so you39。 ll need to set up a Web 3 container to experiment with them。 the process for setting up Tomcat as your container and then the Struts and Tiles packages is described in the next section, in stepbystep fashion. These instructions also show you how to install this article39。 s sample code. Once you39。 ve finished with that, you39。 re ready to continue with the article. The Example 1 application doesn39。 t take advantage of Struts and Tiles。 it demonstrates the pagecentric approach. By paring it with Example 2, you39。 ll see how much more structured and manageable Struts and Tiles can make your Web development. Finally, Example 3 demonstrates how straightforward it is to add functionality to a Struts and Tiles Web application that39。 s already up and running. Installing Struts and Tiles The following instructions have been tested on Linux with the J2SE SDK, Ant , Tomcat , and Struts . If you encounter difficulties with different versions of these packages, you may want to change to the versions specified here to get acquainted with Struts and Tiles setup and development. Start up the Tomcat server by typing ./ (if you are running UNIX) or ./ (if you are running Windows). Verify that Tomcat is up and running properly by pointing your Web browser to The Examples application is shipped with Tomcat by default. If it doesn39。 t work, then something went wrong with Tomcat。 see the Tomcat documentation to resolve the issue. Hello, World: A first attempt To take a look at our first example, follow these steps: Change to the EX1_INSTALL directory. Edit the file and fill in an appropriate value for . The value can either be an absolute or a relative path, although if you are inexperienced with how Ant works, it is probably best to use an absolute path. Type ant deploy. This will build the first example application into a WAR file ready for deployment, then deploy it to Tomcat. If you get an error indicating that Ant could not be found, see step 3 in the “ Installing Struts and Tiles” section and make certain that Ant is in your path. Point your Web browser to You should see a Hello, World page. The Example 1 Web application is a very simple illustration of mon Web application functionality. All but the simplest of applications require a consistent user interface from page to page. Usually this means that all pages have a mon logo, 4 top banner, top or left navigation bar, body, and footer. In Example 1, I have purposely hardcoded the mon items in each page to demonstrate a point. Beginners at Web application development typically add new pages of functionality by copying and pasting existing code into new documents. It is easy to see how this approach can quickly bee unwieldy. With every addition, the process of changing mon page elements, such as a menu or a logo, takes longer and is more prone to error. Clearly, the copyandpaste approach is a terrible model for any application that will grow beyond a few pages. Astute readers will realize that JSP technology provides functionality to include content from other servlets and pages. Why don39。 t we just use the jsp:include/ tag to incorporate mon elements? That would certainly make those elements easier to change. If you need to change the menu, just change the file containing the menu. All other pages use the jsp:include/ tag to pull in the content from the menu, so they automatically pick up the changes. But this approach falls short when the actual layout needs to change or when file。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。