///1 The write-back of the direct page jump is not an ajax call (only @RequestMapping is used) 1 in the
control
, model.addObject("parentMenus", parentMenus); /////////////// /////////////////////////////////////////////////One key, corresponding to value
2, model.addAttribute
@RequestMapping(value = "/edit")
public void edit(Long id,Model model) {
if (id != null) {
User roledetl = userService.getUserForEditById(id);
model.addAttribute("roledetl", roledetl);
List<Organization> orgs= organizationService.getOrganization();
model.addAttribute("orgs", orgs);
// model.addAttribute("areas", acountService.getDictDataListByTypeCodeAndParentId(StaticUtil. PROVINCE_CITY, organization.getCityId()));
}
// model.addAttribute("provinces", acountService.getDictDataListByTypeCode(StaticUtil.PROVINCE_CITY));
// model.addAttribute("roledetl",null);
}
方法二 model.addObject("parentMenus", parentMenus); //////
/////////////////////////////////////////////////////////一个key,对应对个value
<c:forEach items="${parentMenus}" var="parent">
<c:choose>
<c:when test="${parent.isleaf=='0'}">
<div class="titleArea_normal" ><i class="icon_spgl"></i>${parent.menuName}</div>
<div class="box3" style="display: none">
<c:forEach items="${parent.childs}" var="item">
<c:choose>
<c:when test="${!empty item.url}">
<a class="list" href="${pageContext.request.contextPath}${item.url}" target="mainFrame"><span>${item.menuName}</span></a>
</c:when>
<c:otherwise>
<a class="list" href="javascript:void(0)" target="mainFrame"><span>${item.menuName}</span></a>
</c:otherwise>
</c:choose>
</c:forEach>
</div>
</c:when>
<c:when test="${parent.isleaf=='1'}">
<a class="titleArea_normal firstShow" href="${pageContext.request.contextPath}${parent.url }" target="mainFrame"><i class="icon_home1"></i>${parent.menuName}<input type="hidden"/></a>
</c:when>
</c:choose>
</c:forEach>
====================================================================
jsp中
<%-- <c:choose>
<c:when test="${roledetl.status==1}">
<input class="width_240" name="status" value=" 有效" />
</c:when>
<c:when test="${roledetl.status==0}">
<input class="width_240" name="status" value=" 无效" />
</c:when>
</c:choose> --%>
<%-- <c:if test="${roledetl.status==1}">
<input class="width_240" name="status" value=" 有效" />
</c:if> --%>
<select name="status" class="width_240">
<option value="1" <c:if test="${roledetl.status==1}">selected="selected"</c:if>>有效</option>
<option value="0" <c:if test="${roledetl.status==2}">selected="selected"</c:if>>无效</option>
</select>
<select name="status" class="width_240">
<option value="0" selected="selected">===请先选择===</option>
<c:forEach items="${item}" var="item" >
<option value="${item.id }" selected="selected">${item.name }</option>
</c:forEach>
</select>
==========================================================
实例,注意引入jstl标签
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<td><select name="org" class="width_240">
<option value="0" selected="selected">===请先选择===</option>
<c:forEach items="${orgs}" var="item" >
<option value="${item.id }" >${item.orgName }</option>
</c:forEach>
</select>
</td>
@RequestMapping(value = "/edit")
public void edit(Long id,Model model) {
if (id != null) {
User roledetl = userService.getUserForEditById(id);
model.addAttribute("roledetl", roledetl);
List<Organization> orgs= organizationService.getOrganization();
model.addAttribute("orgs", orgs);
// model.addAttribute("areas", acountService.getDictDataListByTypeCodeAndParentId(StaticUtil.PROVINCE_CITY, organization.getCityId()));
}
// model.addAttribute("provinces", acountService. getDictDataListByTypeCode(StaticUtil.PROVINCE_CITY));
// model.addAttribute("roledetl",null);
}
============================== ============================
Method 3 directly uses @ResponseBody combined with ajax, those who use this label will not jump according to road strength , but combined with ajax to write back to the callback function (the content of return in the method)
Transmission of springmvc values (from background to foreground)
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326967589&siteId=291194637
Recommended
Ranking