Fragmet of web.xml:
<servlet>
<servlet-name>Foo Servlet</servlet-name>
<servlet-class>foo.FooServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>testParamName</param-name>
<param-value>value1,value2</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Foo Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Fragmet of servlet FooServlet.java:
public class FooServlet extends HttpServlet {
public void init() throws ServletException {
super.init();
//...
String[] params = this.getInitParameter("testParamName").split(",");
for(String param : params) {
//...
}
}
// ...
}
No comments:
Post a Comment