This seems like it should work, but I just can’t seem to figure out why, hoping a fresh set of eyes can spot what must be something very obvious…
I pass an object from my controller to my jsp file, but trying to parse the object with EL just will not work, it works as a scriptlet though, its driving me crazy 🙂
Using Spring 3.0 MVC
Model:
public class Table {
private String mId;
private ArrayList<Row> mRows;
public String getId() {
return mId;
}
Controller:
Table table = new Table();
table.setId("test");
ModelAndView mav = new ModelAndView();
mav.addObject("table",table);
mav.setViewName("report");
return mav;
JSP File:
<!-- this works -->
<%
Table table = (Table)request.getAttribute("table");
System.out.println(table.getId());
%>
<!-- this does not work -->
${table.getId}
Error:
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/report.jsp at line 33
30:
31: <!-- this dows not work -->
32:
33: ${table.getId}
34:
35: </body>
36: </html>
javax.el.PropertyNotFoundException: Property 'getId' not found on type com.platform.server.portal.model.Table
change
private String mId;toprivate String id;and
${table.getId}to${table.id}you do not need to and can not use accessor method like that.
if it must be mId then change
public String getId()topublic String getMid()and
${table.getId}to${table.mId}