Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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
Java 无法使用EL从servlet上下文获取init参数_Java_Jsp_Servlets_El - Fatal编程技术网

Java 无法使用EL从servlet上下文获取init参数

Java 无法使用EL从servlet上下文获取init参数,java,jsp,servlets,el,Java,Jsp,Servlets,El,我试图获取web.xml文件中定义的init参数的值。但是我得到了httpstatus 500异常 在JSP文件中获取init参数的代码: init param: ${pageContext.servletContext.initParameter.mob} web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

我试图获取
web.xml
文件中定义的
init参数的值。但是我得到了
httpstatus 500
异常

在JSP文件中获取
init参数的代码:

init param: ${pageContext.servletContext.initParameter.mob}
web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <welcome-file-list>
    <welcome-file>one/index.html</welcome-file>
  </welcome-file-list>
<context-param>
<param-name>mob</param-name>
<param-value>nokia</param-value>
</context-param>
</web-app>

one/index.html
暴民
诺基亚

当我尝试使用jsp语法在没有EL的情况下获取init参数时没有问题。但由于它的错误。有谁能告诉我如何使用EL得到这个表达式吗

${initParam['mob']} 
或许


${pageContext.servletContext.initParameter['mob']}

您的问题是什么?@confile问题在于->无法在jsp中使用EL从web.xml获取init param值。请使用EL表达式从servlet上下文获取init参数。