SSM controller 返回List<String> jsp页面用foreach输出

首先一定要引入包

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

我的jsp部分代码,其中也包括直接<%=%>的方式取值,也包括<c:foreach><c:out></c:out></c:foreach>嵌套的输出List<String>结构的数据

<%@ page import="java.util.List" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%
    String title = (String)request.getAttribute("title");
    String date = (String)request.getAttribute("date");
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <base href="<%=basePath%>">
    <title>!!!</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/casedetail.css" rel="stylesheet">
</head>

<body>

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"><div class="container-fluid"></div></nav>
<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar"></div>//侧边导航栏

<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">案例信息</div>
                <div class="panel-body">
                        <h1 class="artitle"><%=title %></h1>
                        <p class="postmeta">
                            <span class="posttime"><%=date %></span>
                        </p>
                            <div class="infobox" style="padding-left: 7%;">
                                <div class="panel-group">
                                    <div class="col-md-9">
                                        <table>
                                        <c:forEach var="i" items="${secondary}">
                                                <tr>
                                                    <td><p style="float: left;"><c:out value="${i}"></c:out></p></td>
                                                </tr>
                                        </c:forEach>
                                        </table>
                                    </div>
                                </div>
                            </div>
                </div>
            </div>
        </div>
    </div><!--/.row-->
</div><!--/.main-->

<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>

</body>

</html>

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值