mybatis+jstl表达式

来源:互联网 发布:大音希声大象无形 知乎 编辑:程序博客网 时间:2024/06/10 17:02

写了一个特别简单的小例子,使用struts1+mybatis+spring,,,其中做了一个增删改查,

结果遇到了一个特别无知的错误!以后一定要记住,不能再犯了!

我在数据库中建的表的字段是xx_xx这种格式的,例如notice_title,在pojo实体类中定义的属性是noticeTitle这种形式的,

在做查找所有数据的时候,sql语句中对各个字段起了别名,但是别名没有与pojo类的属性名对应,导致resultMap对应的类不能与自己起的别名对应,导致不能进行实体类封装值


 public ActionForward show(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        List<Notice> noticeList = noticeService.getNoticeList();
        request.setAttribute("noticeList", noticeList);
        return mapping.findForward("begin");
    }


<table border="1">
    <tr>
        <td>选择</td>
        <td>主题</td>
        <td>内容</td>
        <td>发表时间</td>
        <td>备注</td>
        <td>编辑人员</td>
    </tr>
    <c:forEach var="notices" items="${requestScope.noticeList }" >
    <tr>
        <td><input type="checkbox" name="keyid" value="${notices.keyid}"/></td>
        <td>${notices.noticeTitle}</td>
        <td>${notices.noticeContent }</td>
        <td>${notices.noticePublishTime}</td>
        <td>${notices.noticeComment}</td>
        <td>${notices.noticeEditor }</td>
    </tr>
    </c:forEach>
</table>


1 0