Servelt从web.xml中取得参数

web.xml

<servlet>

<!--全局

 <context-param>
  <param-name>pageSize</param-name>
  <param-value>5</param-value>
 </context-param>

-->
  <servlet-name>SearchItemServlet</servlet-name>
  <servlet-class>com.hugui.drp.basedata.web.SearchItemServlet</servlet-class>
  <init-param>
   <param-name>pageSize</param-name>
   <param-value>5</param-value>
  </init-param>
  
 </servlet>
 
 <servlet-mapping>
  <servlet-name>SearchItemServlet</servlet-name>
  <url-pattern>/servlet/item/SearchItemServlet</url-pattern>
 </servlet-mapping>





SearchItemServlet.java
String  pageSize = this.getServletConfig().getInitParameter("pageSize");

//对应取全局变量this.getServletContext().getInitParameter("pageSize");


你可能感兴趣的:(java,xml,Web,servlet)