I have a Controller which returns a custom object of type Course:
Then, in my JSP view, I try to output it by:Code:return new ModelAndView( getSuccessView(), "course", myCourseObject );
Here is my tld file:Code:<courses:courselist coursesVar="${course}"></courses:courselist>
Then, in my actual tag, I am attempting to output information about this object:Code:<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>courses</shortname> <info>An tag library for use with the Course Registration System</info> <tag> <name>courselist</name> <tagclass>courses.util.CourseListingTag</tagclass> <info>Prints a listing of courses in a pretty table</info> <attribute> <name>coursesVar</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> </taglib>
Trying to access this controller, I receive this exception:Code:@Override public int doStartTag() throws JspException { logger.debug( "doStartTag -- with coursesVar= "+ coursesVar ); StringBuffer buffer = new StringBuffer(); Object obj = ExpressionEvaluationUtils.evaluate("coursesVar", this.coursesVar, Course.class, pageContext); if( obj == null ) { buffer.append( "courses attribute null"); } else { buffer.append( "courses attribute not null"); } buffer.append( "<br>obj: " + obj + " as: " + obj.getClass()+ "<br>" ); try { pageContext.getOut().println( buffer.toString() ); } catch (IOException e) { logger.error( "IOException in CourseListingTag!"); throw new JspException( "IOException when starting courselisting tag", e ); } return EVAL_BODY_INCLUDE; }
Eventually, once I figure out how to do this, I want to make it so I can use my couses:courselisting tag to output a set of Course objects retrieved from Hibernate in a nice table.Code:javax.servlet.ServletException: Attribute value "courses.model.entities.Course@1917a08" is neither a JSP EL expression nor assignable to result class [courses.model.entities.Course]
Any ideas on how to make this work? Thanks


Reply With Quote