我无法在我的 .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/