您的位置:首页 > 职场人生

Web.xml

2004-12-06 15:46 387 查看
接触web.xml很长时间了,只是常用最简单的几项,还用不好。Pebble自己实现了简单而实用的MVC的框架,读源码时发现在web.xml里设置比较多,如果不搞懂,朝下读会比较费力,今天决心找个全面的资料解读一下。
[align=left]从http://java.sun.com/developer/Books/javaserverpages/servlets_javaserver/ 去下载 《More Servlets and JavaServer Pages》 第五章 Controlling Web Application Behavior with web.xml[/align]
[align=left] [/align]
[align=left] Web.xml 里的各元素不仅大小写敏感,而且顺序敏感,所以我们必须按以下顺序来配置。[/align]
[align=left] [/align]
[align=left]• icon. The icon element designates the location of either one or two image files that an IDE or GUI tool can use to represent the Web application. For details, see Section 5.11 (Documenting Web Applications).[/align]
[align=left]• display-name. The display-name element provides a name that GUI tools might use to label this particular Web application. See Section 5.11.[/align]
[align=left]• description. The description element gives explanatory text about the Web application. See Section 5.11.[/align]
[align=left]• distributable. The distributable element tells the system that it is safe to distribute the Web application across multiple servers. See Section 5.15.[/align]
[align=left]• context-param. The context-param element declares application-wide initialization parameters. For details, see Section 5.5 (Initializing and Preloading Servlets and JSP Pages).[/align]
[align=left]• filter. The filter element associates a name with a class that implements the javax.servlet.Filter interface. For details, see Section 5.6 (Declaring Filters).[/align]
[align=left]• filter-mapping. Once you have named a filter, you associate it with one or more servlets or JSP pages by means of the filtermapping element. See Section 5.6.[/align]
[align=left]• listener. Version 2.3 of the servlet API added support for event listeners that are notified when the session or servlet context is created, modified, or destroyed. The listener element designates the event listener class. See Section 5.14 for details.[/align]
[align=left]• servlet. Before you assign initialization parameters or custom URLs to servlets or JSP pages, you must first name the servlet or JSP page. You use the servlet element for that purpose. For details, see Section 5.3.[/align]
[align=left]• servlet-mapping. Servers typically provide a default URL for servlets: http://host/webAppPrefix/servlet/ServletName. However, you often change this URL so that the servlet can access initialization parameters (Section 5.5) or more easily handle relative URLs (Section 4.5). When you do change the default URL, you use the servletmapping element to do so. See Section 5.3.[/align]
[align=left]• session-config. If a session has not been accessed for a certain period of time, the server can throw it away to save memory. You can explicitly set the timeout for individual session objects by using the setMaxInactiveInterval method of HttpSession, or you can use the session-config element to designate a default timeout.[/align]
[align=left]For details, see Section 5.10.[/align]
[align=left]• mime-mapping. If your Web application has unusual files that you want to guarantee are assigned certain MIME types, the mimemapping element can provide this guarantee. For more information, see Section 5.12.[/align]
[align=left]• welcome-file-list. The welcome-file-list element instructs the server what file to use when the server receives URLs that refer to a directory name but not a filename. See Section 5.7 for details.[/align]
[align=left]• error-page. The error-page element lets you designate the pages that will be displayed when certain HTTP status codes are returned or when certain types of exceptions are thrown. For details, see Section 5.8.[/align]
[align=left]• taglib. The taglib element assigns aliases to Tag Library Descriptor files. This capability lets you change the location of the TLD files without editing the JSP pages that use those files. See Section 5.13 for more information.[/align]
[align=left]• resource-env-ref. The resource-env-ref element declares an administered object associated with a resource. See Section 5.15.[/align]
[align=left]• resource-ref. The resource-ref element declares an external resource used with a resource factory. See Section 5.15.[/align]
[align=left]• security-constraint. The security-constraint element lets you designate URLs that should be protected. It goes hand-inhand with the login-config element. See Section 5.9 for details.[/align]
[align=left]• login-config. You use the login-config element to specify how the server should authorize users who attempt to access protected pages. It goes hand-in-hand with the security-constraint element. See Section 5.9 for details.[/align]
[align=left]• security-role. The security-role element gives a list of security roles that will appear in the role-name subelements of the security-role-ref element inside the servlet element. Declaring the roles separately could make it easier for advanced IDEs[/align]
[align=left]to manipulate security information. See Section 5.9 for details.[/align]
[align=left]• env-entry. The env-entry element declares the Web application’s environment entry. See Section 5.15.[/align]
[align=left]• ejb-ref. The ejb-ref element declares a reference to the home of an enterprise bean. See Section 5.15.[/align]
[align=left]• ejb-local-ref. The ejb-local-ref element declares a reference to the local home of an enterprise bean. See Section 5.15.[/align]
[align=left] [/align]
如果你down到这片材料,就会发现它讲得非常清楚明了,几乎无须翻译。把它配置好可以给我们工作带来很多方便和安全。常看些成熟的系统配置,争取慢慢达到灵活运用之。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 XML web 休闲