Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Servlets 使用servletconfig的初始化参数不起作用_Servlets_Web.xml - Fatal编程技术网

Servlets 使用servletconfig的初始化参数不起作用

Servlets 使用servletconfig的初始化参数不起作用,servlets,web.xml,Servlets,Web.xml,在web.xml文件中 <init-param> <param-name> n1 </param-name> <param-value> 100 </param-value> </init-param> <init-param> <param-name> n2 </param-name> <param-value> 200 </par

web.xml
文件中

<init-param>
    <param-name> n1 </param-name>
    <param-value> 100 </param-value>
 </init-param>

 <init-param>
    <param-name> n2 </param-name>
    <param-value> 200 </param-value>
 </init-param>

它返回n1和n2的空值

Put all web.xml please haks伙计们,我得到了答案。实际上,web.xml中存在一个问题,我使用了错误的servlet名称。
ServletConfig conf=getServletConfig();
String s1=conf.getInitParameter("n1");
String s2=conf.getInitParameter("n2");
out.println("n1 value is " +s1+ " and n2 is " +s2);