JSP: EL expression is not evaluated [duplicate]

2019-01-13 01:29发布

This question already has an answer here:

I have a JSP page running on Tomcat 5.5. I have the following code:

 <c:forEach var="i" begin="1" end="10" step="1">
  <c:out value="${i}" />
  <br />
</c:forEach>

The output I am getting is:

${i} 
${i} 
${i} 
${i} 
${i} 
${i} 
${i} 
${i} 
${i} 
${i} 

I cant work out why the forEach loop is working but the output is not working. Any help any one could give would be great.

标签: java jsp el taglib
9条回答
贼婆χ
2楼-- · 2019-01-13 02:24

I know it's supposed to be on by default, but I run across pages now and again (or even the same page that changes behavior) where the EL processing doesn't happen. Adding the following to the top of any such pages should resolve the issue:

<%@ page isELIgnored="false" %> 

I add it to every page because it doesn't hurt, and I still don't know the root cause that occasionally causes a page to stop interpreting the EL expressions.

查看更多
够拽才男人
3楼-- · 2019-01-13 02:27

Make sure to include the relevant namespaces in the web.xml. Just try to replace

<web-app>

with something like

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0"
  metadata-complete="true">

It fixed it for me. You can find the correct namespaces for your Tomcat instance in the example apps that come with a Tomcat install.

查看更多
SAY GOODBYE
4楼-- · 2019-01-13 02:28

Use tomcat6. It doesn't requires any configuration for EL in web.xml.

查看更多
登录 后发表回答