无法使用 EL 从 servlet 上下文获取初始化参数
unable to get init-parameter from servlet context using EL
我正在尝试获取 web.xml
文件中定义的 init parameter
的值。但是我收到 Http Status 500
异常。
在 JSP 文件中获取 init parameter
的代码:
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>
当我尝试使用 jsp 语法在没有 EL 的情况下获取初始化参数时没有问题。但是使用 EL 会导致错误。谁能告诉我如何使用 EL
得到这个
尝试使用这个表达式。
${initParam['mob']}
或者也许
${pageContext.servletContext.initParameter['mob']}
我正在尝试获取 web.xml
文件中定义的 init parameter
的值。但是我收到 Http Status 500
异常。
在 JSP 文件中获取 init parameter
的代码:
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>
当我尝试使用 jsp 语法在没有 EL 的情况下获取初始化参数时没有问题。但是使用 EL 会导致错误。谁能告诉我如何使用 EL
得到这个尝试使用这个表达式。
${initParam['mob']}
或者也许
${pageContext.servletContext.initParameter['mob']}