EL 표현식, JSTL, 맵 집합에서 키의value 가져오기
9847 단어 el 표현식
1: 백그라운드 코드는 다음과 같습니다.
package cn.gov.csrc.cms.action;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import cn.gov.csrc.base.action.BaseAction;
import cn.gov.csrc.cms.model.RoleInfo;
import cn.gov.csrc.cms.service.RoleService;
import cn.gov.csrc.cms.util.PageData;
import cn.gov.csrc.cms.util.PageNavUtil;
import com.opensymphony.xwork2.ActionContext;
@Controller
@Scope("prototype")
public class RoleAction extends BaseAction<RoleInfo>{
private static Logger logger = LoggerFactory.getLogger(RoleAction.class);
private static final long serialVersionUID = 1L;
private Integer page;
private Map<String, Object> dataMap;
private RoleService roleService;
public RoleAction() {
dataMap = new HashMap<String, Object>();
}
@Resource
public void setRoleService(RoleService roleService) {
this.roleService = roleService;
}
@Action(value = "RoleAction_find", results={@Result(name = "success", location = "/ucenter/sys/roleList.jsp")})
public String find(){
page = page == null ? 1 : page < 1 ? 1:page;
int pageSize = 5;
PageData<RoleInfo> pageData = this.roleService.getRoles(page,pageSize,model.getRoleName());
dataMap.clear();
dataMap.put("dataList", pageData.getPageData());
dataMap.put("totalCount", pageData.getTotalCount());
dataMap.put("totalPage", pageData.getTotalPage());
dataMap.put("currentPage", page);
dataMap.put("pageNav", PageNavUtil.getPageNavHtml(page.intValue(), pageSize, pageData.getTotalCount(), 15));
ActionContext.getContext().getSession().put("dataMap", dataMap);
return "success";
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
}
2: 프론트 데스크 jsp 코드는 다음과 같다.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="../../common/include_tag.jsp"%>
<%@ include file="../../common/page_var.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=pageTitle%> - </title>
<%@ include file="../../common/page_head.jsp"%>
<script type="text/javascript">
function add(){
$.jBox("iframe:#.action", {
title: " ",
width: 700,
height: 320,
buttons: {}
});
}
function edit(id){
$.jBox("iframe:#.action?id="+id, {
title: " ",
width: 700,
height: 320,
buttons: {}
});
}
function delRole(id,msg){
$.jBox.confirm(" ["+msg+"] ?", " ", function (v, h, f) {
if (v == 'ok'){
$.post("#.action",{id:id},function(responseText){
if(responseText==true){
$.jBox.info(" , ", " ",{top: '20%'});
}else{
$.jBox.error(" ", " ");
}
});
}
return true;
},{top: '40%'});
}
function changeRoleStatus(id,status){
$.jBox.confirm(" "+(status==0?" ":" ")+" ?", " ", function (v, h, f) {
if (v == 'ok'){
$.post("#.action",{id:id,status:status},function(responseText){
if(responseText==true){
$.jBox.info(" , ", " ",{top: '20%'});
}else{
$.jBox.error(" ", " ");
}
});
}
return true;
},{top: '40%'});
}
function roleResourceSet(roleId){
$.jBox("iframe:#.action?roleId="+roleId, {
title: " ",
width: 700,
height: 550,
buttons: {}
});
}
$().ready(function(){
pilicat.alternately('list');
});
</script>
</head>
<body>
<div style="height: 60px; overflow: hidden">
<%@ include file="../u_top.jsp"%>
</div>
<div id="frame_side">
<%@ include file="../u_login_info.jsp"%>
<jsp:include page="../u_left_menu.jsp" flush="true">
<jsp:param name="current" value="roles" />
</jsp:include>
</div>
<div id="body_box">
<table cellpadding="0" cellspacing="0" border="0" class="icon">
<tr>
<td></td>
</tr>
</table>
<span style="text-align: left;padding-left: 10px;"> -> -> </span>
<table cellpadding="0" cellspacing="0" border="0" class="table">
<tbody>
<tr>
<td valign="top" align="right">
<form action="" method="get" name="search" id="search">
<table cellpadding="0" cellspacing="5" border="0">
<tbody>
<tr>
<td><a class="button_4" href="javascript:;" onclick="add();"> </a></td>
</tr>
</tbody>
</table>
</form>
</td>
</tr>
</tbody>
</table>
<div class="rounded table">
<form action="" method="get" name="search_form" id="search_form">
<table width="100%" cellpadding="0" cellspacing="0" border="0"
class="box_top">
<tr>
<td class="title"> </td>
<td></td>
</tr>
</table>
</form>
<form action="" method="post" name="manage" id="manage">
<table class="list td_align" cellpadding="0" cellspacing="1"
border="0">
<tr>
<td class="field_head" width="30"> </td>
<td class="field_head"> ID</td>
<td class="field_head"> </td>
<td class="field_head"> </td>
<td class="field_head"> </td>
</tr>
<c:forEach items="${dataMap.dataList}" var="dataItem" varStatus="rowStatus">
<tr>
<td><input type="checkbox" name="cbitem" value="${dataItem.id }" /></td>
<td>${dataItem.id}</td>
<td>${dataItem.roleName}</td>
<td>${dataItem.roleDesc}</td>
<td class="operation"><a href="javascript:;"
onclick="edit(${dataItem.id});"> <img
src="./css/images/operation/pencil.png"
title=" " />
</a> <a href="javascript:;"
onclick="roleResourceSet(${dataItem.id});"> <img
src="./css/images/operation/folder.png"
title=" " />
</a> <a href="javascript:;"
onclick="delRole(${dataItem.id},'${dataItem.roleName}');"> <img
src="./css/images/operation/trashcan_delete.png"
title=" " />
</a></td>
</tr>
</c:forEach>
</table>
<table class="table top_line">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="all_action"><input name="allChkbox"
id="allChkbox" type="checkbox"
onclick="pilicat.select_all(this.form);" /></td>
<td> / </td>
<td class="operation"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<table class="page" cellpadding="0" cellspacing="5">
<tr>
<td>
<div id="pageNav" class="scott">
<font color="#88af3f"> ${dataMap["totalCount"]} , ${dataMap["totalPage"]} </font>
${dataMap["pageNav"]}
</div>
</td>
</tr>
</table>
</div>
<%@ include file="../u_bottom.jsp"%>
</div>
</body>
</html>
참고: 주로 다음 페이지로 나뉘어 표시됩니다.
<div id="pageNav" class="scott">
<font color="#88af3f"> ${dataMap["totalCount"]} , ${dataMap["totalPage"]} </font>
${dataMap["pageNav"]}
</div>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
EL 표현식, JSTL, 맵 집합에서 키의value 가져오기서문: 오늘 프로젝트에서 맵 메모리list와 일반 대상을 사용했지만 jsp에 표시될 때 문제가 생겼습니다. 나중에 찾아보고 해결했습니다. 지금 기록해 두면 나중에 읽을 수 있습니다. 1: 백그라운드 코드는 다음과 같...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.