<C: set> tag
<C: set> tag is used to set the variable values and object properties.
<C: set> tag is the <jsp: setProperty> tag behavior twin brother.
The reason why this label is useful to use it, because it will calculate the value of the expression, and then use the results to set the value of an object or JavaBean java.util.Map object.
Syntax
<c:set var="<string>" value="<string>" target="<string>" property="<string>" scope="<string>"/>
Attributes
<C: set> tag has the following attributes:
Attributes | description | If necessary | Defaults |
---|---|---|---|
value | The value to be stored | no | Subject content |
target | To modify an object property belongs | no | no |
property | To modify the properties | no | no |
var | Variable to store information | no | no |
scope | Scope var attribute | no | Page |
If you specify a target attribute, property attributes need to be specified.
Examples Demo
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title>c:set 标签实例</title> </head> <body> <c:set var="salary" scope="session" value="${2000*2}"/> <c:out value="${salary}"/> </body> </html>
Results are as follows:
4000