侧边栏壁纸
  • 累计撰写 781 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论
标签搜索

example

Dettan
2021-04-10 / 0 评论 / 0 点赞 / 92 阅读 / 1,470 字
温馨提示:
本文最后更新于 2022-04-30,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
/ 后端 / Web / JSP / example
<%@page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.learn.dao.HousekeepingtypeDao" %>
<%@ page import="com.learn.entity.HousekeepingtypeEntity" %>
<%@ page import="java.util.List" %>

<%
ServletContext context = request.getSession().getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
Object service = ctx.getBean("housekeepingtypeDao");
HousekeepingtypeDao dao = (HousekeepingtypeDao) service;
List<HousekeepingtypeEntity> types = dao.queryList(new HashMap<>());
request.setAttribute("types", types);
%>

...上面往request里设置属性后,下面用${属性名} 就能直接取出来.

<div class="form-group">
<div class="col-sm-2 control-label">类型值</div>
<div class="col-sm-10">
<select class="form-control">
<c:forEach items="$" var="each">
<option value="$">$</option>
</c:forEach>
</select>
</div>
</div>

0

评论区