JSP expression language not working
Solution 1
Add the following to the top
<%@ page isELIgnored="false"%>
Solution 2
I faced some problem and the above solution worked. But what is the issue ? I run another project, but I don't do this import. But still it works properly.
I'm referring to this solution:
<%@ page isELIgnored="false"%>
Solution 3
I was mistakenly using the wrong import.
I got import org.springframework.web.portlet.ModelAndView;
auto-imported when I thought I had org.springframework.web.servlet.ModelAndView;
imported.
It almost drove me nuts.
Thanks.
skip
Updated on June 13, 2022Comments
-
skip about 2 years
I am not able to get
${}
expression working on my.jsp
page.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); } }
I am getting only the header "Our Entire Customer Database" displayed when I get the page displayed.
It's driving me nuts and I cant figure out what I am missing.
Could someone please help me understand why is it happening?
Many thanks.