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参数。