zoukankan      html  css  js  c++  java
  • jsp获取struts2查询到的数据

    1.在struts2的方法中利用查询语句查询到结果,然后再对结果进行封装,jsp根据封装获取相关信息

    struts2的查询和封装方法:

     private List<FreeMarkerDetail>  freemarkerdetaillist;

    这个是封装的方法类
       /**
         * @Title: queryFeedBackById
         * @Description: 根据意见反馈Id查询意见反馈详情
         * @param @return
         * @param @throws ServiceException    参数
         * @return String    返回类型
         * @throws
         */
    public String queryFreeMarkerById() throws ServiceException{ freemarkerdetaillist = freemarkerDetailService.queryFreeMarkerDetailById(freemarkerId); ServletActionContext.getRequest().setAttribute("freemarkerdetailList", freemarkerdetaillist); return "toFreeMarkerDetailPage"; }

    2.然后安装  ServletActionContext.getRequest().setAttribute("freemarkerdetailList", freemarkerdetaillist); 进行封装

    3.jsp页面根据封装获取相关内容:

                         <table class="sx_table">
                                            <tr>
                                                <td style=" 10%"><label class="name">主键编号</label></td>
                                                <td style=" 10%"><label class="name">关联主键</label></td>
                                                <td style=" 10%"><label class="name">文件名</label></td>
                                                <td style=" 50%"><label class="name">文件路径</label></td>
                                                <td style=" 20%"><label class="name">创建时间</label></td>
                                            </tr>
                                            <c:forEach items="${requestScope.freemarkerdetailList }" var="freemarkerdetailList">
                                                <tr>
                                                    <td style=" 10%"><label class="name"></label>
                                                        <span class="toname">
                                                            ${freemarkerdetailList.filesDetailId} </span></td>
                                                    <td style=" 10%"><label class="name"></label>
                                                        <span class="toname">
                                                            ${freemarkerdetailList.filesId} </span></td>
                                                    <td style=" 10%"><label class="name"></label>
                                                        <span class="toname">
                                                            ${freemarkerdetailList.filesDetailName } </span></td>
                                                    <td style="word-break:break-all; word-wrap:break-word;  50%;"><label class="name"></label>
                                                        <span class="toname">
                                                            <a href="${freemarkerdetailList.filesDetailUrl }"> 
                                                            ${freemarkerdetailList.filesDetailUrl }</a> 
                                                        </span>
                                                    </td>
                                                    <td style=" 20%"><label class="name"></label>
                                                        <span class="toname"> <fmt:formatDate
                                                                value="${freemarkerdetailList.createTime }"
                                                                pattern="yyyy-MM-dd HH:mm:ss" />
                                                    </span></td>
                                                </tr>
                                            </c:forEach>
                                        </table>

    上面就是jsp获取查询到内容的方法。

  • 相关阅读:
    kotlin中值范围
    kotlin中集合
    kotlin数据解构
    Java 8 Lambda 表达式
    kotlin 之内联函数
    kotlin之函数的范围和泛型函数
    kotlin函数的参数和返回值
    kotlin 之单表达式函数
    kotlin使用中辍标记法调用函数
    kotlin之函数的基本用法
  • 原文地址:https://www.cnblogs.com/lr393993507/p/5434517.html
Copyright © 2011-2022 走看看