web.xml 常量获取

<?xml version="1.0"encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
.......
</web-app>
<description>
当servlet的URL定义为其他文件类型的扩展名,该文件类型将不能访问,而访问了servlet
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
 <display-name>myweb</display-name><!--站点名称-->
 <description>这里是站点描述</description>
 <icon>
 <small-icon>/images/small.gif</small-icon><!--小图标的路径16*16,必须为gif jpge格式-->
 <large-icon>/images/large.gif</large-icon><!--大图标的路径32*32,必须为gif jpge格式-->
 </icon>
 <!--如果存在<distributable/>则代表该站点能在多个JSP Container之间分散执行(分布式)-->
 <distributable/>




 <context-param><!--环境参数,设置常量,取得常量 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所对应的URL-->
   <filter-name>filterName</filter-name>
   <url-pattern>/filterName</url-pattern>
   <dispatcher>REQUEST|INCLUDE|FORWARD|ERROR</dispatcher><!--filter对应的请求方式,有4种方式,默认REQUEST-->
 </filter-mapping>
 <listener><!--设定Listener接口-->
 <listener-class>listener.ListenerClassName</listener-class>
 </listener>
 <servlet><!--声明servlet的数据-->
   <servlet-name>servletName</servlet-name>
   <servlet-class>servlet.servletName</servlet-class>
   <init-param><!--初始化参数,可以在init()中使用ServletConfig().getInitParamenter("name")取得-->
   <param-name>name</param-name>
   <param-value>123</param-value>
   </init-param>
   <load-on-startup>n</load-on-startup><!--站点启动时,此servlet会被自动加载执行,1表示最早,2,3...-->

 </servlet>
 <servlet-mapping><!--定义servlet所对应的URL-->

 <servlet-name>name</servlet-name>
 <url-pattern>/name</url-pattern>
 </servlet-mapping>
 <session-config><!--设置session超时时间(20分钟)默认按服务器配置-->
 <session-timeout>20</session-timeout>
 </session-config>
 <mime-mapping><!--定义某个扩展名和某个MIME Type做映射-->
 <extension>doc</extension>
 <mime-type>application/vnd.ms-word</mime-type>
 </mime-mapping>
 <welcome-file-list><!--设置首页列表-->
   <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
 <error-page><!--将错误代码对应到WEB站点的资源路径-->
   <error-code>错误代码</error-code>Exception
   <location>/路径/</location>

 </error-page>
 <error-page><!--将异常的种类对应到WEB站点的资源路径-->
   <exception-type>Exception</exception-type>
   <location>/路径/</location>

 </error-page>

 <jsp-config><!--JSP的相关配置-->
 <taglib><!--JSP所用到的Tag Library-->
 <taglib-uri>URI</taglib-uri>
 <taglib-location>/WEB-INF/lib/xxx.tld</taglib-location>
 </taglib>
 <jsp-property-group>
 <description>此设定的说明</description>
 <display-name>Name</display-name>
 <url-pattern>URL</url-pattern><!--此设定影响的范围-->
 <el-ignored>true|false</el-ignored><!--true表示不支持EL语法-->
 <scripting-invalid>encoding</scripting-invalid><!--jsp的编码-->
 <include-coda>...jspf</include-coda><!--JSP的结尾,扩展名.jspf-->
 </jsp-property-group>
 </jsp-config>
 <resource-ref><!--利用JNDI取得站点可利用的资源-->
 <description>资源说明</description>
 <res-ref-name>资源名称</res-ref-name>
 <res-type>资源种类</res-type>
 <res-auth>Application|Container</res-auth><!--资源经由什么许可-->
 <res-sharing-scope>Shareable|Unshareable</res-sharing-scope><!--资源是否可以共享,默认为Shareable-->
 </resource-ref>
</web-app>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值