配置web.xml文件时1是干什么用的?

liu79 2005-10-05 03:13:38
<servlet>
<servlet-name>initservlet</servlet-name>
<servlet-class>com.bb.eoa.util.initServlet</servlet-class>
<init-param>
<param-name>log4j-init-file</param-name>
<param-value>config/log.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

上面有一句<load-on-startup>1</load-on-startup>,不懂是什么意思
另外<load-on-startup>1</load-on-startup>中的“1”可不可以设成2或者3什么的,这样是不是标注的启动顺序?
...全文
9104 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
doway 2005-10-06
  • 打赏
  • 举报
回复
除了那段 E 文没有好好看(E 文还没学好),其他的都没说到点子上。

大多数 Servlet 是在用户第一次请求的时候由应用服务器创建并初始化,但 <load-on-startup>n</load-on-startup> 可以用来改变这种状况,该元素说明某个 Servlet 在应用程序启动的时候就立即装入 Servlet,并初始化它。

这是一个非常有用的特点,如果楼主想不出这样做有什么用,就当它不存在好了。:)
  • 打赏
  • 举报
回复

优先级!

12345..代表优先级别
kenny1979 2005-10-05
  • 打赏
  • 举报
回复
搬来一段Servlet specification应该够说服力的了吧。
The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the web application. The optional contents of these element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-start-up value.
liu79 2005-10-05
  • 打赏
  • 举报
回复
到底哪一个是正确的答案哪,我蒙咧
owenchwz 2005-10-05
  • 打赏
  • 举报
回复
如果我没记错的话,非加载顺序,应该是WEB服务器启动后经过的时间(时间单位是MS?)后将servlet实例化,没有该选项则在有请求时再实例化.
huangdeji 2005-10-05
  • 打赏
  • 举报
回复
upupupupupupupup
onray 2005-10-05
  • 打赏
  • 举报
回复
1.加载2.顺序
majy 2005-10-05
  • 打赏
  • 举报
回复
对,就是启动顺序的

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧