JSP 表达式语言不起作用

标签 jsp spring-mvc spring-3

我无法在我的 .jsp 页面上使用 ${} 表达式。

displayAllCustomers.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


<html>
    <body>
        <h3>Our Entire Customer Database</h3>
        <ul>
            <c:forEach items="${allCustomers}" var="customer">
                <li>${customer.name}</li>
            </c:forEach>
        </ul>
    </body>
</html>

dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                                      http://www.springframework.org/schema/tx
                                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                                      http://www.springframework.org/schema/aop 
                                      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <import resource="applicationContext.xml"/>     

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>


    <bean name="/displayAllCustomers" class="mypackage.DisplayAllCustomersController">
        <property name="customerManagementService" ref="customerManagementService" />
    </bean>     

</beans>

DisplayAllCustomersController.java

public class DisplayAllCustomersController {

    private CustomerManagementService customerManagementService;
    public void setCustomerManagementService(CustomerManagementService customerManagementService) {
        this.customerManagementService = customerManagementService;
    }

    @RequestMapping("/displayAllCustomers")
    public ModelAndView displayAllCustomers() {
        List<Customer> allCustomers = customerManagementService.getAllCustomers();
        return new ModelAndView("displayAllCustomers", "allCustomers", allCustomers);
    }
}

当我显示页面时,我只看到标题“我们的整个客户数据库”。

这让我发疯,我不知道我错过了什么。

有人可以帮我理解为什么会这样吗?

非常感谢。

最佳答案

在顶部添加以下内容

<%@ page isELIgnored="false"%>

关于JSP 表达式语言不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8257721/

相关文章:

java - spring security 从数据库中获取用户 ID

java - 访问 - 了解用户从哪个国家访问我的应用程序

java - jsp中的自动完成文本框

java - tomcat 5.5升级到tomcat 7.0需要重新编译所有JSP文件吗

java - Spring:url 没有正确解析链接

spring security - 如何在自定义 SPEL 方法中修改 @PostAuthorize 的返回对象?

javascript - 无法通过JS更新隐藏字段

java - 具有不同 UsernamePasswordAuthToken 的多个 AuthenticationProvider 可以在没有回退身份验证的情况下对不同的登录表单进行身份验证

java - jar 和 war 中的 Spring 3.1 ehCache 将在 war : XML configuration 中使用 jar

spring-3 - Spring 3.1 : BeanDefinitionStoreException on startup