<%@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="${types}" var="each">
<option value="${each.name}">${each.name}</option>
</c:forEach>
</select>
</div>
</div>
评论区