C In JSTL: key points and skills of set labels

Source: Internet
Author: User
C: The set tag has two different settings: var and target. Var "version" is used to set the scope attribute, and target "version" is used to set the bean attribute or Map value. Both versions have two forms: ry and ry. There is only another way to put values.★Var "version" <c: set var = "userLevel" scope = "session" value = "Cowboy"/> <c: set var = "fido" value = "$ {person. dog} "/> <c: set var =" user "scope =" session "> Sheriff, bariff, Cowgirl </c: set> If" value "is null, the attribute specified by "var" will be deleted! If the property specified by "var" does not exist, an attribute is created, but a new attribute is created only when "value" is not null.★Target "version" <c: set target = "$ {petMap}" property = "dogName" value = "Clover" scope = "session"/> <c: set target = "$ {person}" property = "name" >$ {foo. name} </c: set> If "target" is a Map, "property" specifies a key of the Map. If "target" is a bean, "property" specifies a member field of the bean. If the target expression is null, the container throws an exception. If the target expression is not a Map or bean, the container throws an exception. If the "target" expression is a bean, but the bean does not have a member field that matches the "property", the container will throw an exception.★The key points for using the c: set tag cannot have the "var" and "target" attributes at the same time. "Scope" is optional. If this attribute is not used, the page scope is used by default. Specifically, when this attribute is not used, the container searches for the page scope, request scope, session scope, and application scope in sequence. If the scope attribute specified by "var" is not found, the container creates a new attribute in the page scope. If the object specified by "target" cannot be found, the container throws an exception.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.