English 中文(简体)
EL expressions won t executed in Tomcat 5.5, but working in tomcat 6.0.20
原标题:

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);
}

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>

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

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}

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

Thanks in advance...

最佳回答

But, when I am deploying war file in Unix (CentOS) platform, where I have Tomcat 5.5, the EL expression doesn t get executed and giving me output like:

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

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. 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 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>
问题回答

Are you sure that you have included JSTL library either on Tomcat or your Web Application s lib folder?

These links will help you:

How to set up Tomcat to work with JSTL

How to reference and use jstl in your web application

Thanks to BalusC for his excellent answer. I had the exact same problem that he diagnosed above, and his solution got me part of the way there. However, I also had to make sure that various JSP and JSTL dependencies of my application were all compatible. In particular, I was referencing JSTL 1.2 and this problem didn t go away until I changed that dependency to JSTL 1.1.2 (at which point I had to also add an explicit dependency on taglibs.standard:1.1.2).

The following blog post provides a lot more information on compatibility between different versions: http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签