web.xml之Servlet配置

 

定义:

 <servlet>
  <servlet-name>myservlet</servlet-name>
  <servlet-class>com.myapp.controller.MyFirstServlet</servlet-class>
  <init-param>
   <param-name>ServletInitParam</param-name>
   <param-value>你好</param-value>
  </init-param>
  <load-on-startup>0</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>myservlet</servlet-name>
  <url-pattern>/myFirstServlet.do</url-pattern>
 </servlet-mapping>


<servlet-name>指定servlet的名称
<servlet-class>指定servlet的类的名称
<init-param>用来定义参数,可有多个init-param。在servlet类中通过getInitParamenter(String name)方法访问初始化参数
<load-on-startup>指定web应用启动时,装载servlet的次序。当值为负数或未定义时Servlet容器将在web客户首次访问此servlet时加载它;当值为正数或未定义时Servlet容器先加载数值小的servlet
<url-pattern>指定servlet所对应的URL

你可能感兴趣的:(Web,servlet,String,url)