使用Spring MVC在JSP页面上显示未解析的EL表达式列表

我正在尝试做一些非常简单的事情。 我只想在Spring MVC应用程序中的JSP页面上显示一个列表。 我已经google了很多,并且有很多例子(包括Stackoverflow上的一些例子),但它不适合我。 我正在使用Maven和Spring 3.2.4。 这些是我的文件:

Item.java

public class Item { private final String value; public Item(String value) { this.value = value; } public String getValue() { return value; } } 

MainController.java

 @Controller public class MainController { @RequestMapping("/") public String home(ModelMap map) { final List items = new ArrayList(); items.add(new Item("Value 1")); items.add(new Item("Value 2")); items.add(new Item("Value 3")); items.add(new Item("Value 5")); map.addAttribute(items); return "list"; } } 

的List.jsp

       Naked List  

Naked List


applicationContext.xml中

             

webxml

   Naked List  contextConfigLocation classpath:applicationContext.xml    org.springframework.web.context.ContextLoaderListener    spring  org.springframework.web.servlet.DispatcherServlet  1   spring /   

的pom.xml

  4.0.0 org.ne.nakedlist org.ne.nakedlist 0.0.1-SNAPSHOT war Naked List Naked List  1.7 3.2.4.RELEASE    javax.servlet javax.servlet-api 3.0.1 provided   log4j log4j 1.2.9   taglibs standard 1.1.2   javax.servlet jstl 1.2   javax.inject javax.inject 1   org.springframework spring-webmvc ${org.springframework.version}   org.springframework spring-web ${org.springframework.version}      org.apache.maven.plugins maven-compiler-plugin 2.5.1  ${java.version} ${java.version} ${project.build.sourceEncoding}    org.apache.maven.plugins maven-dependency-plugin 2.3   package  copy     org.mortbay.jetty jetty-runner 7.4.5.v20110725 jetty-runner.jar        nakedlist  

当我运行应用程序时,我得到的是:

 Naked List ${item.value} 

我真的希望我错过了一些非常明显的配置,这是一个快速简单的解决方案。

这里的问题是您的Web应用程序版本。 你在Servlet 2.3上

   

在此版本中, 默认情况下会忽略EL 。 你需要添加

 <%@ page isELIgnored ="false" %> 

在JSP的顶部。

我真的建议你更新你的servlet版本。 我们现在正在进入3.1,在2.3上没有意义。


有关

  • 如何查看服务器使用的EL版本