使用freemaker在页面显示数据库内容失败=。=求破
我有freemaker做一个页面用来显示数据库的内容,用下拉条出现的内容。然后各种失败,搞不清楚错误,特地来发帖请教.Action代码:
private List courseClassList;
public List getcourseClassList() {
return courseClassList;
}
public String ccList() {
courseClassList = this.getServMgr().getCourseClassService().getCourseClasslist();
return "ccList";
}
Service代码:
private static final String SQL_GET_COURSE_CLASS_LIST = "select * from courseclass order by classid asc";
public List getCourseClasslist() {
return jt.queryForList(SQL_GET_COURSE_CLASS_LIST);
}
ftl页面引用的代码:(courseClass_add.ftl)
<tr>
<td class="item">所属分类</td>
<td><select name="parentId">
<option value="0">--根分类--</option>
<#list courseClassList as course>
<option value="${course.CLASSID}"><@p.indent course.CLASSID?length/>${course.CLASSNAME}</option>
</#list>
</select><td>
</tr>
xml里面的设置:
<result name="ccList">courseClass_add.ftl</result>
--------------------编程问答-------------------- 错误信息呢?courseClassList不要设置到会话里面,ftl应该不认识courseClassList这个变了吧 --------------------编程问答-------------------- 楼主先排查错误:
在freemarker里面 取${courseClassList} 看有没有值。 --------------------编程问答--------------------
FreeMarker template error!
Expression courseClassList is undefined on line 26, column 16 in manage/courseclass/courseClass_add.ftl.
The problematic instruction:
----------
==> list courseClassList as course [on line 26, column 9 in manage/courseclass/courseClass_add.ftl]
in user-directive p.page [on line 1, column 1 in manage/courseclass/courseClass_add.ftl]
----------
Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression courseClassList is undefined on line 26, column 16 in manage/courseclass/courseClass_add.ftl.
这些是错误信息,这是26行的, <#list courseClassList as course> --------------------编程问答--------------------
${courseClassList}里面没有值,也是错误的.
Expression courseClassList is undefined on line 1, column 3 in manage/courseclass/cc.ftl.
The problematic instruction:
----------
==> ${courseClassList} [on line 1, column 1 in manage/courseclass/cc.ftl]
----------
Java backtrace for programmers:
--------------------编程问答-------------------- =。=补充一下,数据库里面有东西,同学能出来,我的出不来数据。
补充:Java , Web 开发