<c:set>标记是setProperty动作的JSTL的版本。该标签是有用的,因为它计算一个表达式,并使用结果来设定一个JavaBean或java.util.Map对象的值。
<c:set>标记具有以下属性:
属性 | 描述 | Required | Default |
---|---|---|---|
value | 需要保存的信息 | No | body |
target | Name of the variable whose property should be modified | No | None |
property | Property to modify | No | None |
var | Name of the variable to store information | No | None |
scope | Scope of variable to store information | No | Page |
如果指定目标,属性也必须指定。
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title><c:set> Tag Example</title> </head> <body> <c:set var="salary" scope="session" value="${2000*2}"/> <c:out value="${salary}"/> </body> </html>这将产生以下结果:
4000