如何用jstl定义一个map并赋值
1个回答
展开全部
定义一个Map可以使用jsp:useBean
往Map里填值可以使用c:set 标签
例子:
Java code
<%-- Create a hash map and store it in session scope --%>
<jsp:useBean id='map' class='java.util.HashMap'
scope='session'>
<%-- Add initial key/value pairs stored in the hash
map. The following <c:set> actions are only invoked
when the hash map is created. --%>
<c:set target='${map}' property='inline skates'
value='149.99'/>
<c:set target='${map}' property='hockey stick'
value='29.99'/>
<c:set target='${map}' property='elbow pads'
value='19.99'/>
<c:set target='${map}' property='puck'
value='5.99'/>
</jsp:useBean>
往Map里填值可以使用c:set 标签
例子:
Java code
<%-- Create a hash map and store it in session scope --%>
<jsp:useBean id='map' class='java.util.HashMap'
scope='session'>
<%-- Add initial key/value pairs stored in the hash
map. The following <c:set> actions are only invoked
when the hash map is created. --%>
<c:set target='${map}' property='inline skates'
value='149.99'/>
<c:set target='${map}' property='hockey stick'
value='29.99'/>
<c:set target='${map}' property='elbow pads'
value='19.99'/>
<c:set target='${map}' property='puck'
value='5.99'/>
</jsp:useBean>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询