EL 表达式不会在 Tomcat 5.5 中执行,但在 tomcat 6.0.20 中有效 [英] EL expressions won't executed in Tomcat 5.5, but working in tomcat 6.0.20

查看:22
本文介绍了EL 表达式不会在 Tomcat 5.5 中执行,但在 tomcat 6.0.20 中有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 spring-web-mvc 开发我的应用程序...

I am developing my application using spring-web-mvc...

现在在我的控制器它返回如下:

Now at my Controller it returns like this :

  public class InterfacesManageController implements Controller {
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception  {

    Map<String, Object> myModel = new HashMap<String, Object>();

    myModel.put("interfacesList", this.interfacesSecurityProcessor.findByAll(0, null, null, null));

    return new ModelAndView("common", "model", myModel);
}

现在,我的 JSP 包含以下代码:

Now, my JSP contains following code :

<c:forEach items="${model.interfacesList}" var="prod">
     <c:out value="${prod.id}"/> <c:out value="${prod.name}"/><br><br>
</c:forEach>

现在,当我在拥有 tomcat 6.0.20、ognl 2.6.11 的 Windows 平台上执行此操作时,它给了我我想要的确切输出:

Now when i am executing this to Windows platform where i have tomcat 6.0.20, ognl 2.6.11 it's giving me exact output which i want like :

117 eth1

118 eth1

119 eth0

但是,当我在具有 tomcat 5.5 的 unix (cent os) 平台上部署 war 文件时,ognl 表达式不会被执行并给出如下输出:

But, when i am deploying war file in unix (cent os) platform, where i have tomcat 5.5, the ognl expression doesn't get executed and giving me output like :

${prod.id} ${prod.name}

谁能有解决办法,ognl表达式版本和tomcat版本应该是什么问题?

Can anybody have solution, what should be the problem with ognl expression version and tomcat version ?

提前致谢...

推荐答案

但是,当我在使用 Tomcat 5.5 的 Unix (CentOS) 平台上部署 war 文件时,EL 表达式不会被执行并给出如下输出:

${prod.id} ${prod.name}

换句话说,EL 表达式根本没有被计算并且显示为纯文本?这可能有以下一种或多种原因:

In other words, the EL expression doesn't get evaluated at all and is showing as plain text? That can have one or more of the following causes:

  1. 有问题的应用服务器不支持 JSP 2.0.
  2. web.xml 未声明为 Servlet 2.4 或更高版本.
  3. JSP的<%@page %>配置了isELIgnored=true.
  4. web.xml中配置了true>.
  1. Application server in question doesn't support JSP 2.0.
  2. The web.xml is not declared as Servlet 2.4 or higher.
  3. The <%@page %> of JSP is configured with isELIgnored=true.
  4. The web.xml is configured with <el-ignored>true</el-ignored> in <jsp-config>.

Tomcat 5.5 是 Servlet 2.4/JSP 2.0,所以 #1 可以被划掉.我假设在部署之前您没有更改 webapp 中的任何内容,因此 #3 和 #4 可能会被划伤.现在离开#2.也许您将其声明为 Tomcat 6.0 的 Servlet 2.5,而 Tomcat 5.5 只能理解为 Servlet 2.4.这样,一切都会变得一团糟,因为 Tomcat 将退回到最低兼容性模式.您需要将 web.xml 重新声明为 Servlet 2.4,以便它可以在 Tomcat 5.5 和 6.0 中运行.声明应如下所示:

Tomcat 5.5 is Servlet 2.4/JSP 2.0, so #1 can be scratched. You didn't change anything in webapp before deploying I assume, so #3 and #4 can likely be scratched. Now left #2. Maybe you declared it as Servlet 2.5 for Tomcat 6.0 while the Tomcat 5.5 only understands up to with Servlet 2.4. This way everything will become a mess as Tomcat would then fallback to least compatibility modus. You need to redeclare web.xml as Servlet 2.4 so that it will work in both Tomcat 5.5 and 6.0. The declaration should look like:

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

    <!-- Here you go. -->

</web-app>

这篇关于EL 表达式不会在 Tomcat 5.5 中执行,但在 tomcat 6.0.20 中有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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