jaron插件的用法
一.dict字典插件的基本用法:
<%@ taglib prefix="dict" uri="http://www.evan.jaron.com/tags/dict" %>
实体类属性加注解:
/**投诉建议申请 状态 01:处理中,02:已处理*/
@DictValue(type = "FEED_STATE")
@Column(name="FEED_STATE")
private String feedState;
1.根据字典项的key,获取字典项的value
<dict:lookupDictValue type="TALK_STATE" key="${fwBusinessTalk.talkState}" />
2.根据字典项的类型,查询集合
<dict:loadDictList var="addridTime" type="ADDRID_TIME" />
<dict:loadDictList var="fabricList" type="FABRIC_TYPEL" parentKey="ROOT"/>
循环输出list的值,进行显示
<c:forEach items="${addridTimeList}" var="item">
<option value="${item.dictKey}" >${item.dictValue0}</option>
</c:forEach>
3.根据字典项的类型,查询集合,在js中调用
<dict:loadDictList var="orderStatus" type="ORDER_STATUS" toJson="true"/>
<script>
var dateTime = '${orderStatus}';
var dateJson = JSON.parse(dateTime);
var status = data.orderStatus;
return dateJson[status].dictValue0;
</script>
4.在java的controller中转字典项
//处理数据中的字典项
dictionaryHelper.decodePage(page);
5.在页面循环显示字典项,将值显示在select中,并且分级显示,如图:
<select id="business" name="business" class="form-control"> <!-- 行业类型 --> <dict:loadDictList var="industryList" type="INDUSTRY_TYPE" parentKey="ROOT" /> <c:forEach items="${industryList}" var="industry_parent"> <c:if test="${industry_parent.available==true}"> <optgroup label="${industry_parent.dictValue0}"> <dict:loadDictList var="industry_child" type="INDUSTRY_TYPE" parentKey="${industry_parent.dictKey}"/> <c:forEach items="${industry_child}" var="industry_child"> <c:if test="${industry_child.available==true}"> <option value="${industry_child.dictKey}">${industry_child.dictValue0}</option> </c:if> </c:forEach> </optgroup> </c:if> </c:forEach> </select>
一.area字典插件的基本用法:
<%@ taglib prefix="area" uri="http://www.evan.jaron.com/tags/area" %>
<area:lookupFullAreaName areaCode="${addr.province}"/>
// 查询所有"省" List<SysArea> areaList= AreaUtils.getAllCity(AreaHelper.SHENG_LEVEL); resultMap.put("areaList", areaList);
/** * 根据区域code查询当前区域下一集所有区域(luy) * @param map * @param model * @param request * @param response */ @RequestMapping(value = "/getAreaNextLevel", method = {POST}) @ResponseBody public String getAreaNextLevel(@RequestParam() Map<String,Object> map,HttpServletResponse response){ String areaCode = MapUtils.getString(map, "areaCode"); Map<String, Area> areaMap= areaHelper.lookupNextLevelAreas(areaCode); // 结果集 HashMap<String, Object> resultMap = new HashMap<String, Object>(); resultMap.put("areaList", areaMap); return JsonUtils.toJson(RequestUtils.successResult(resultMap)); }