以【?nid=】的形式进行页面的跳转

html文件

## index##
<body>
    {% for k,v in user_dict.items %}
        <li style="margin: 50px"><a href="/detail?nid={{ k }}">{{ k }}</a></li>
    {% endfor %}

</body>
## detail##
<body>
    <h1>详细信息</h1>
    <h2>姓名:{{ detail_info.name }}</h2>
    <h2>年龄:{{ detail_info.age }}</h2>
</body>

view

user_dict = {
    '1': {'name': 'jack1', 'age': '12'},
    '2': {'name': 'jack2', 'age': '12'},
    '3': {'name': 'jack3', 'age': '12'},
    '4': {'name': 'jack4', 'age': '12'},
}


def index(request):
    return render(request, 'index.html', {'user_dict': user_dict})


def detail(request):
    nid = request.GET.get('nid')
    detail_info = user_dict[nid]
    return render(request,'detail.html',{'detail_info':detail_info})
<h3>新闻发布系统>>新闻管理>>查询新闻</h3> <center> <form action="SelectNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"> </form><br> <table border="1" width="70%" cellpadding="0" cellspacing="0"> <tr align="center"> <td>编号</td> <td>标题</td> <td>类型</td> <td>发布人</td> <td>发布日期</td> <td>状态</td> <td>是否头条</td> <td colspan="4">操作</td> </tr> <c:forEach items="${newsList }" var="news"> <tr align="center"> <td><input type="checkbox" name="newsIds" value="${news.nid}"></td> <td>${news.nid }</td> <td>${news.title }</td> <td>${news.type }</td> <td>${news.userName }</td> <td>${news.pubtime }</td>adadada <td> <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> </td> <td> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> </td> <td>${news.top==0?"是":"否" }</td> <td> <a href="NewsDetail?nid=${news.nid }&op=show">查看</a> <c:if test="${user.rule==0 || user.uid ==news.uid }"> <a href="NewsDetail?nid=${news.nid }&op=update">修改</a> </c:if> <c:if test="${user.rule==0 }"> <a href="newsDelete.jsp?nid=${news.nid }">  删除</a> </c:if> <c:if test="${user.rule==0 }">  审核</c:if> </td> </tr> </c:forEach> </table> <c:if test="${user.rule==0}"> <button type="button"><a href="javascript:void(0)" onclick="banchDelete()">批量删除</a></button> </c:if> </center> </body> <script type="text/javascript"> function banchDelete(){ var idsArray = document.getElementsByName("newsIds"); var nidArray=[];//用于存储需要删除的新闻编号 for(k in idsArray){ if(idsArray[k].checked){ nidArray.push(idsArray[k].value); } } if(nidArray.length==0){ alert("请选择要删除的新闻"); return } window.location.href="./newsBanchDelete.jsp?nids="+nidArray.join(",");//window.location.href 方法是javascript的页面跳转代码 } </script>
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值