java 在jsp中启用el
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1038046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
enabling el in jsp
提问by Greenhorn
How can I enable EL expression in JSP version 2.0? Every time I'm getting EL expression as an String literal in the JSP as an output.
如何在 JSP 2.0 版中启用 EL 表达式?每次我将 EL 表达式作为 JSP 中的字符串文字作为输出时。
Here's the DD which the container is using to sending request to servlet, and then servlet dispating request to JSP:
这是容器用来向 servlet 发送请求,然后 servlet 向 JSP 发送请求的 DD:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>check</servlet-name>
<servlet-class>Welcome</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>check</servlet-name>
<url-pattern>/Momma.do</url-pattern>
</servlet-mapping>
</web-app>
I've not ignored any el in JSP too. Am I still missing something?
我也没有忽略 JSP 中的任何 el。我还缺少什么吗?
回答by amischiefr
Your web.xml file looks fine for JSP 2.0. If you are having problems accessing EL on specific pages try adding the following to the top of the individual JSP page:
您的 web.xml 文件对于 JSP 2.0 来说看起来不错。如果您在访问特定页面上的 EL 时遇到问题,请尝试将以下内容添加到各个 JSP 页面的顶部:
<%@ page isELIgnored="false" %>
Since you are using JSP 2.0 I think that EL is ignored by default so you can can add the following to your web.xml to enable it for all pages:
由于您使用的是 JSP 2.0,我认为默认情况下会忽略 EL,因此您可以将以下内容添加到您的 web.xml 中,以便为所有页面启用它:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-enabled>true</el-enabled>
<scripting-enabled>true</scripting-enabled>
</jsp-property-group>
</jsp-config>
回答by André Luís Tomaz Dionisio
for facet 2.5
面向 2.5
<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
</web-app>
回答by danilo
With the web.xml below scriplets and expression languages will be enabled on pages jsp explicitly:
使用下面的 web.xml 脚本和表达式语言将在页面 jsp 上显式启用:
WEB-INF\web.xml
WEB-INF\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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>
<scripting-invalid>false</scripting-invalid>
</jsp-property-group>
</jsp-config>
</web-app>
https://docs.oracle.com/cd/E24329_01/web.1211/e21049/web_xml.htm#WBAPP545
https://docs.oracle.com/cd/E24329_01/web.1211/e21049/web_xml.htm#WBAPP545

