JSP中<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>标签的使用

来源:互联网 发布:淘宝巴巴爸爸是正品吗 编辑:程序博客网 时间:2024/05/22 06:55

JSP中<%@taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c”%>的使用
前端代码

  • 注:subsidyType与返回的ConstantDict的对象的constantDict.id对应
<div class="form-group">                            <label for="subsidyType" class="col-sm-3 control-label">补贴类型</label>                            <div class="col-sm-9">                                <select class="form-control" id="subsidyType" name="subsidyType">                                    <c:forEach var="constantDict" items="${constantDicts}">                                        <option value="${constantDict.id}">${constantDict.constantName}</option>                                    </c:forEach>                                </select>                            </div>    </div>

后端代码
需要给前台返回一个List

@RequestMapping    public ModelAndView showDefaultPage() {        List<ConstantDict> constantDicts = constantDictBiz.findByConstantTypeCode("subsidy_type");        ModelAndView mav = new ModelAndView();        mav.setViewName(defaultPage);        mav.addObject("constantDicts", constantDicts);        return mav;    }
0 0