NutzCN Logo
问答 在module中把数据传递给前台html的时候怎么获取map类型的
发布于 2523天前 作者 wx_bfdej3jpo10okmffl9if 1694 次浏览 复制 上一个帖子 下一个帖子
标签:

在前台html中可以使用下面的方式取出列表的数据

之后
${member.id!}这种方式,
但是我传了一个map类型的。怎么取都不对。有没有人有试过的

17 回复

下面为后台传递过来的json数据

{
   data: {
      pager: {
         pageSize: 15,
         page: 1,
         count: 2,
         entities: [{
            pk_memberinfo: "98a23171c66c4d93b86f64d3cf8f8274",
            mem_number: "100010",
            mem_name: "罗晨月",
            mem_sex: "1",
            mem_age: "5",
            mem_telephone: "13910871920",
            mem_starttime: "2018-01-10",
            mem_endtime: "2019-01-09",
            mem_enable: "0",
            pk_membertype: "2d5384597f3e41f7b2d8bbfc017f2367",
            ts: "2018-01-09 11:00:44",
            createUser: "",
            dr: false,
            id: 2
         }, {
            pk_memberinfo: "0541e29552dd4905b2fd67a6a0533559",
            mem_number: "10009",
            mem_name: "元祖",
            mem_sex: "0",
            mem_age: "4",
            mem_telephone: "13801013043",
            mem_starttime: "2018-01-09",
            mem_endtime: "2019-01-08",
            mem_enable: "0",
            pk_membertype: "a2996a9156ee4c93a74c9e2cc600cc30",
            ts: "2018-01-09 10:40:18",
            createUser: "",
            dr: false,
            id: 1
         }],
         url: "/thunder-web/member/list?page=",
         simplePager: false,
         maxLength: 1
      },
      sexmap: {
         "0": "男",
         "1": "女"
      },
      "0": "男",
      "1": "女"
   },
   operationState: "SUCCESS"
}

我想获取sexmap这个数据。因为列表数据中的性别我存的是单独的数字 要转成中文显示。

模板贴一下看看

<!--# 
layout("/layout/default.html",{"menu":["business","member_list"],"breadcrumbs":[{"name":"会员列表"}]}){ 
 #-->
<table
	class="table  table-hover general-table table-striped table-bordered">
	<thead>
		<tr>
			<th colspan="7">
				<div class="row">
					<div class="col-md-3 ">
						<form action="${base}/member/search" class="search-form">
							<div class="input-group">
								<span class="input-group-addon">关键字</span> <input type="text"
									class="form-control" placeholder="请输入关键词进行检索..."
									style="font-weight: 500" name="key"
									value="${obj.data.pager.paras.key!}" data-type="reg"
									data-reg="/^[\u4e00-\u9fa5\d\w]{1,}$/" data-default="Search..."
									data-error="请输入搜索关键词" placeholder="请输入角色名检索"> <span
									class="input-group-addon search-btn" style="cursor: pointer;"><i
									class="fa fa-search"></i> GO</span>
							</div>
						</form>
					</div>
					<div class="col-xs-6"></div>
					<div class="col-xs-3">
						<!--# if(hasPermission('member.add')){ #-->
						<a href="${base}/member/add" class="btn btn-info btn-sm"><i
							class="fa fa-plus-circle"></i> 添加</a>
						<!--# } #-->
					</div>
				</div>
			</th>
		</tr>
		<tr>
			<th class="center">序号</th>
			<th class="hidden-phone center">会员卡号</th>
			<th class="center">姓名</th>
			<th class="center">性别</th>
			<th class="center">开始时间</th>
			<th class="center">结束时间</th>
			<th class="center">操作</th>
		</tr>
	</thead>
	<tbody>
		<!--#for(member in obj.data.pager.entities){#-->
		<tr class="center">
			<td>${member.id!}</td>
			<td>${member.mem_number!}</td>
			<td>${member.mem_name!}</td>
			<td>${member.mem_sex!}</td>
			<td>${member.mem_starttime!}</td>
			<td>${member.mem_endtime!}</td>
			<td class="center">
				<div class="hidden-sm hidden-xs btn-group">
					<!--# if(hasPermission('member.detail')){ #-->
					<a class="btn btn-xs btn-success"
						href="${base}/member/detail/${member.id!}"> <i
						class="ace-icon fa fa-check bigger-120"></i> 详情
					</a>
					<!--# } #-->
					<!--# if(hasPermission('member.edit')){ #-->
					<a class="btn btn-xs btn-info" href="${base}/member/edit/${member.id!}">
						<i class="ace-icon fa fa-pencil bigger-120"></i> 编辑
					</a>
					<!--# } #-->
					<!--# if(hasPermission('member.delete')){ #-->
					<button class="btn btn-xs btn-danger btn-delete"
						data-url='/member/delete' data-id='${member.id!}'>
						<i class="ace-icon fa fa-trash-o bigger-120"></i> 删除
					</button>
					<!--# } #-->
				</div>
			</td>
		</tr>
		<!--#	} #-->
	</tbody>
	<tfoot>
		<!--# 
		if(obj.data.pager.entities.~size == 0){
		#-->
		<tr>
			<td colspan="7" class="null-pager">没有符合条件的数据</td>
		</tr>
		<!--#
		}else{
		#-->
		<tr>
			<td colspan="7">
				<div class="pull-right">${obj.data.pager.pagerBar!}</div>
			</td>
		</tr>
		<!--#
		}
	#-->
	</tfoot>
</table>
<!--# } #-->

我想 在下面的代码中进行获取map

<td>${member.mem_sex!}</td>

看上去没写错的样子,是后台报错了吗?

我的意思是怎么把 下面的 sexmap: {
"0": "男",
"1": "女"
},取出来

{
   data: {
      pager: {
         pageSize: 15,
         page: 1,
         count: 2,
         entities: [{
            pk_memberinfo: "98a23171c66c4d93b86f64d3cf8f8274",
            mem_number: "100010",
            mem_name: "罗晨月",
            mem_sex: "1",
            mem_age: "5",
            mem_telephone: "13910871920",
            mem_starttime: "2018-01-10",
            mem_endtime: "2019-01-09",
            mem_enable: "0",
            pk_membertype: "2d5384597f3e41f7b2d8bbfc017f2367",
            ts: "2018-01-09 11:00:44",
            createUser: "",
            dr: false,
            id: 2
         }, {
            pk_memberinfo: "0541e29552dd4905b2fd67a6a0533559",
            mem_number: "10009",
            mem_name: "元祖",
            mem_sex: "0",
            mem_age: "4",
            mem_telephone: "13801013043",
            mem_starttime: "2018-01-09",
            mem_endtime: "2019-01-08",
            mem_enable: "0",
            pk_membertype: "a2996a9156ee4c93a74c9e2cc600cc30",
            ts: "2018-01-09 10:40:18",
            createUser: "",
            dr: false,
            id: 1
         }],
         url: "/thunder-web/member/list?page=",
         simplePager: false,
         maxLength: 1
      },
      sexmap: {
         "0": "男",
         "1": "女"
      },
      "0": "男",
      "1": "女"
   },
   operationState: "SUCCESS"
}

那你不是已经写了吗?

这块不行 ${member.mem_sex!} 我写成${obj.data.sexmap.get(member.mem_sex!)} 这样就报错

不行是什么意思,没有显示出来还是怎样

${obj.data.sexmap[member.mem_sex]}
01-26 15:59:01.205  DEBUG - [LoggingMethodInterceptor.http-nio-8080-exec-1] [afterInvoke] Obj = [club.zhcs.thunder.module.member.MemberInfoModule$$NUTZAOP] , Return = {
   data: {
      pager: {
         pageSize: 15,
         page: 1,
         count: 4,
         entities: [{
            pk_memberinfo: "4a071c30ab4846fcbdbf6b24146be34d",
            mem_number: "100001",
            mem_name: "晨晨",
            mem_sex: "0",
            mem_age: "3",
            mem_telephone: "13801013033",
            mem_starttime: "2018-01-26",
            mem_endtime: "2018-02-10",
            mem_enable: "0",
            pk_membertype: "2d5384597f3e41f7b2d8bbfc017f2367",
            ts: "2018-01-26 15:14:51",
            createUser: "",
            dr: false,
            id: 5
         }, {
            pk_memberinfo: "108fd41460b84fd5b9f1785c8dd5c041",
            mem_name: "元祖1",
            mem_sex: "1",
            mem_age: "3",
            mem_telephone: "18303031304",
            mem_starttime: "2018-01-25",
            mem_endtime: "2018-01-31",
            mem_enable: "0",
            pk_membertype: "a2996a9156ee4c93a74c9e2cc600cc30",
            ts: "2018-01-25 18:32:55",
            createUser: "",
            dr: false,
            id: 4
         }, {
            pk_memberinfo: "5262dfa0d6f7453e87bccde3b053fb57",
            mem_name: "元祖",
            mem_sex: "0",
            mem_age: "34",
            mem_telephone: "18303031303",
            mem_starttime: "2018-01-25",
            mem_endtime: "2018-01-31",
            mem_enable: "1",
            pk_membertype: "2d5384597f3e41f7b2d8bbfc017f2367",
            dr: false,
            id: 3
         }, {
            pk_memberinfo: "98a23171c66c4d93b86f64d3cf8f8274",
            mem_name: "罗晨月1",
            mem_sex: "1",
            mem_age: "5",
            mem_telephone: "13910871920",
            mem_starttime: "2018-01-10",
            mem_endtime: "2019-01-09",
            mem_enable: "1",
            pk_membertype: "2d5384597f3e41f7b2d8bbfc017f2367",
            dr: false,
            id: 2
         }],
         url: "/thunder-web/member/list",
         simplePager: false,
         maxLength: 10
      },
      sexmap: {
         "0": "男",
         "1": "女"
      },
      "0": "男",
      "1": "女"
   },
   operationState: "SUCCESS"
} , Method = public club.zhcs.titans.utils.db.Result club.zhcs.thunder.module.member.MemberInfoModule.list(int) , args = [1]
NULL
	at org.beetl.core.statement.VarRef.evaluate(VarRef.java:110)
	at org.beetl.core.statement.PlaceholderST.execute(PlaceholderST.java:34)
	at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
	at org.beetl.core.statement.ForStatement.execute(ForStatement.java:144)
	at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
	at org.beetl.core.Tag.doBodyRender(Tag.java:60)
	at org.beetl.core.Tag.getBodyContent(Tag.java:69)
	at org.beetl.ext.tag.LayoutTag.render(LayoutTag.java:104)
	at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
	at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
	at org.beetl.core.statement.Program.execute(Program.java:70)
	at org.beetl.core.Template.renderTo(Template.java:137)
	at org.beetl.core.Template.renderTo(Template.java:103)
	at org.beetl.ext.web.WebRender.render(WebRender.java:120)
	at org.beetl.ext.nutz.BeetlView.render(BeetlView.java:28)
	at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:66)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at club.zhcs.titans.nutz.processor.CSRFProtectPostProcessor.process(CSRFProtectPostProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at club.zhcs.titans.nutz.processor.CSRFProtectPreProcessor.process(CSRFProtectPreProcessor.java:38)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at club.zhcs.titans.nutz.processor.XSSProtectProcessor.process(XSSProtectProcessor.java:20)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at club.zhcs.thunder.chain.WxJsSdkConfigProcessor.process(WxJsSdkConfigProcessor.java:48)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at club.zhcs.thunder.chain.WxUserInjectProcessor.process(WxUserInjectProcessor.java:39)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:126)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
01-26 15:59:01.208  DEBUG - [LogErrorHandler.http-nio-8080-exec-1] 空指针
>>03:59:01:表达式值为空(NULL):get 位于50行 资源:pages/member/list.html
空指针
47|		<td>${member.id!}</td>
48|			<td>${member.mem_number!}</td>
49|			<td>${member.mem_name!}</td>
50|			<td>${obj.data.sexmap.get[member.mem_sex!]}</td>
51|			<td>${member.mem_starttime!}</td>
52|			<td>${member.mem_endtime!}</td>

${obj.data.sexmap[member.mem_sex]} 这么写${obj.data.sexmap(member.mem_sex)} 都报上面的错误

@admin 谢谢 就是你说的问题,解决了。

添加回复
请先登陆
回到顶部