XML聲明,,定義XML的版本,、編碼格式。還有最重要的schema的來(lái)源
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java./xml/ns/j2ee" xmlns:xsi="http://www./2001/XMLSchema-instance" xsi:schemaLocation="http://java./xml/ns/j2ee http://java./xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> ....... </web-app>
<description>
當(dāng)servlet的URL定義為其他文件類型的擴(kuò)展名,該文件類型將不能訪問(wèn),而訪問(wèn)了servlet
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java./xml/ns/j2ee" xmlns:xsi="http://www./2001/XMLSchema-instance" xsi:schemaLocation="http://java./xml/ns/j2ee http://java./xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>myweb</display-name><!--站點(diǎn)名稱--> <description>這里是站點(diǎn)描述</description> <icon> <small-icon>/images/small.gif</small-icon><!--小圖標(biāo)的路徑16*16,必須為gif jpge格式--> <large-icon>/images/large.gif</large-icon><!--大圖標(biāo)的路徑32*32,必須為gif jpge格式--> </icon> <!--如果存在<distributable/>則代表該站點(diǎn)能在多個(gè)JSP Container之間分散執(zhí)行(分布式)--> <distributable/>
<context-param><!--環(huán)境參數(shù),設(shè)置常量,取得常量 this.getInitParameter("context");--> <param-name>context</param-name> <param-value>10000</param-value> </context-param> <filter><!--聲明filter-->
<filter-name>filterName</filter-name> <filter-class>filter.filterName</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping><!--定義filter所對(duì)應(yīng)的URL--> <filter-name>filterName</filter-name> <url-pattern>/filterName</url-pattern> <dispatcher>REQUEST|INCLUDE|FORWARD|ERROR</dispatcher><!--filter對(duì)應(yīng)的請(qǐng)求方式,有4種方式,默認(rèn)REQUEST--> </filter-mapping> <listener><!--設(shè)定Listener接口--> <listener-class>listener.ListenerClassName</listener-class> </listener> <servlet><!--聲明servlet的數(shù)據(jù)--> <servlet-name>servletName</servlet-name> <servlet-class>servlet.servletName</servlet-class> <init-param><!--初始化參數(shù),可以在init()中使用ServletConfig().getInitParamenter("name")取得--> <param-name>name</param-name> <param-value>123</param-value> </init-param> <load-on-startup>n</load-on-startup><!--站點(diǎn)啟動(dòng)時(shí),此servlet會(huì)被自動(dòng)加載執(zhí)行,1表示最早,2,3...-->
</servlet> <servlet-mapping><!--定義servlet所對(duì)應(yīng)的URL-->
<servlet-name>name</servlet-name> <url-pattern>/name</url-pattern> </servlet-mapping> <session-config><!--設(shè)置session超時(shí)時(shí)間(20分鐘)默認(rèn)按服務(wù)器配置--> <session-timeout>20</session-timeout> </session-config> <mime-mapping><!--定義某個(gè)擴(kuò)展名和某個(gè)MIME Type做映射--> <extension>doc</extension> <mime-type>application/vnd.ms-word</mime-type> </mime-mapping> <welcome-file-list><!--設(shè)置首頁(yè)列表--> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <error-page><!--將錯(cuò)誤代碼對(duì)應(yīng)到WEB站點(diǎn)的資源路徑--> <error-code>錯(cuò)誤代碼</error-code>Exception <location>/路徑/</location>
</error-page> <error-page><!--將異常的種類對(duì)應(yīng)到WEB站點(diǎn)的資源路徑--> <exception-type>Exception</exception-type> <location>/路徑/</location>
</error-page>
<jsp-config><!--JSP的相關(guān)配置--> <taglib><!--JSP所用到的Tag Library--> <taglib-uri>URI</taglib-uri> <taglib-location>/WEB-INF/lib/xxx.tld</taglib-location> </taglib> <jsp-property-group> <description>此設(shè)定的說(shuō)明</description> <display-name>Name</display-name> <url-pattern>URL</url-pattern><!--此設(shè)定影響的范圍--> <el-ignored>true|false</el-ignored><!--true表示不支持EL語(yǔ)法--> <scripting-invalid>encoding</scripting-invalid><!--jsp的編碼--> <include-coda>...jspf</include-coda><!--JSP的結(jié)尾,擴(kuò)展名.jspf--> </jsp-property-group> </jsp-config> <resource-ref><!--利用JNDI取得站點(diǎn)可利用的資源--> <description>資源說(shuō)明</description> <res-ref-name>資源名稱</res-ref-name> <res-type>資源種類</res-type> <res-auth>Application|Container</res-auth><!--資源經(jīng)由什么許可--> <res-sharing-scope>Shareable|Unshareable</res-sharing-scope><!--資源是否可以共享,默認(rèn)為Shareable--> </resource-ref> </web-app>
|