load-on-startup的意义

如下一段配置,熟悉SpringMVC的再熟悉不过了:

<!--配置SpringMVC的前端控制器DispatcherServlet-->
<servlet>
    <servlet-name>SpringMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:SpringMVC.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>SpringMVC</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

一、load-on-startup标签的作用


load-on-startup标签可以设置servlet的加载优先级别和容器是否在启动时加载该servlet,如下设置:

<load-on-startup>1</load-on-startup>


当值为0或者大于0时,代表容器启动时加载该servlet。正数的值越小,启动时加载该servlet的优先级越高。如果为负数,则容器启动时不会加载该servlet,只有该servlet被选择时才会加载。

贴一段英文原汁原味的解释如下:
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.

翻译过来的意思大致如下:
1)load-on-startup元素标记容器是否在启动的时候就加载这个servlet(实例化并调用其init()方法)。

2)它的值必须是一个整数,表示servlet应该被载入的顺序

2)当值为0或者大于0时,表示容器在应用启动时就加载并初始化这个servlet;

3)当值小于0或者没有指定时,则表示容器在该servlet被选择时才会去加载。

4)正数的值越小,该servlet的优先级越高,应用启动时就越先加载。

5)当值相同时,容器就会自己选择顺序来加载。

所以,<load-on-startup>x</load-on-startup>,中x的取值1,2,3,4,5代表的是优先级,而非启动延迟时间。

二、load-on-startup标签的意义

<load-on-startup>1</load-on-startup>
  • 如果不写如上代码,代表容器启动时不加载且不初始化,那么当浏览器第一次访问servlet时,才会初始化,那么第一次访问页面会加载很久
  • 加上如上代码后,将在容器启动时就加载并初始化这个servlet,第一次访问相比 不写如上代码 就不会加载那么久。
  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
README.TXT NOTES ON MS-DOS VERSION 5.0 =========================== In this file the following topics are covered: 1. Introduction 2. Solving Setup Problems 2.1 Priam and Everex Hard Disks 2.2 SyQuest Removable Hard Disk 2.3 Bernoulli Drive 2.4 Disk Manager 2.5 SpeedStor and Volume Expansion 2.6 Novell Partitions 2.7 Vfeature Deluxe 2.8 Columbia Data Systems Device Driver 2.9 Incompatible Partition 2.10 WYSE Partitions 2.11 286 Accelerator Cards 2.12 Bernoulli Cache 2.13 AT&T 6300 Computers 2.14 LANtastic 2.15 Western Digital SCSI Hard-Disk Controllers 2.16 Change CONFIG.SYS File 2.17 Toshiba T1600 and a Hard RAM Disk 3. Installing MS-DOS 5.0 on OS/2 Systems 3.1 Installing MS-DOS 5.0 and OS/2 Dual-Boot Systems 3.2 Using the Uninstall Program on an OS/2 System 4. Solving Memory Problems 4.1 386MAX 4.2 All Computers Expanded-Memory Driver 4.3 Bus Master DMA Controller 4.4 HIMEM.SYS Location 4.5 INT15 Access to Extended Memory 4.6 Intel LIM Driver 4.7 Phoenix BIOS and HIMEM.SYS 4.8 QEMM 4.9 XMAEM.SYS and XMA2EM.SYS 5. Solving Problems with Windows 5.1 DOS Applications in Windows Enhanced Mode 5.2 EMM386.EXE Location 5.3 WINA20.386 File 5.4 Windows 3.0 Enhanced Debug Version 5.5 Windows 2.03 5.6 Windows/286 2.1 5.7 Windows 386 and the Upper Memory Area 6. Making Your Hardware Compatible with MS-DOS 5.0 6.1 101-key Keyboards and QBasic/MS-DOS Editor 6.2 Acer 1100/33 6.3 Adaptec Controller Boards 6.4 Amstrad Systems and KEYB.COM 6.5 Hardcard II 6.6 COMPAQ EXTDISK.SYS Driver 6.7 Corel System Drivers 6.8 External Disk Drives 6.9 Mice and MS-DOS Shell 6.10 NCR VGA BIOS 6.11 Olivetti Systems 6.12 Toshiba T3100SX 6.13 Western Digital VGA Card 6.14 Zenith Computers 7. Making Your Network Compatible with MS-DOS 5.0 7.1 3+Share 7.2 AT&T StarGROUP 7.3 DCA 10Net and Word5 7.4 DOS LAN Requester 7.5 I
QEmu虚拟机 做嵌入式开发的朋友试试 调试内核很方便 QEMU emulator version 0.13.0, Copyright (c) 2003-2008 Fabrice Bellard usage: qemu [options] [disk_image] 'disk_image' is a raw hard disk image for IDE hard disk 0 Standard options: -h or -help display this help and exit -version display version information and exit -M machine select emulated machine (-M ? for list) -cpu cpu select CPU (-cpu ? for list) -smp n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets] set the number of CPUs to 'n' [default=1] maxcpus= maximum number of total cpus, including offline CPUs for hotplug, etc cores= number of CPU cores on one socket threads= number of threads on one CPU core sockets= number of discrete sockets in the system -numa node[,mem=size][,cpus=cpu[-cpu]][,nodeid=node] -fda/-fdb file use 'file' as floppy disk 0/1 image -hda/-hdb file use 'file' as IDE hard disk 0/1 image -hdc/-hdd file use 'file' as IDE hard disk 2/3 image -cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) -drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] [,cache=writethrough|writeback|none|unsafe][,format=f] [,serial=s][,addr=A][,id=name][,aio=threads|native] [,readonly=on|off] use 'file' as a drive image -set group.id.arg=value set parameter for item of type i.e. -set drive.$id.file=/path/to/image -global driver.property=value set a global default for a driver property -mtdblock file use 'file' as on-board Flash memory image -sd file use 'file' as SecureDigital card image -pflash file use 'file' as a parallel flash image -boot [order=drives][,once=drives][,menu=on|off] 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n) -snapshot write to temporary files

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

穗余

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值