在jsp中启用el [英] enabling el in jsp

查看:321
本文介绍了在jsp中启用el的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JSP 2.0版中启用EL表达式?每次我在JSP中将EL表达式作为字符串文字作为输出。

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.

这是容器用于向servlet发送请求的DD,然后servlet向JSP发出请求:

Here's the DD which the container is using to sending request to servlet, and then servlet dispating request to JSP:

    <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>

我也没有忽略JSP中的任何el。我还缺少什么吗?

I've not ignored any el in JSP too. Am I still missing something?

推荐答案

你的web.xml文件看起来很适合JSP 2.0。如果您在特定页面上访问EL时遇到问题,请尝试将以下内容添加到单个JSP页面的顶部:

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:

<%@ page isELIgnored="false" %>

由于您使用的是JSP 2.0,我认为默认情况下会忽略EL,因此您可以添加以下内容到你的web.xml为所有页面启用它:

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-config>
  <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-enabled>true</el-enabled>
    <scripting-enabled>true</scripting-enabled>
  </jsp-property-group>
</jsp-config>

这篇关于在jsp中启用el的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆