Velocity determines if the variable is not empty or null

Source: Internet
Author: User

The original #if ($mobile)This is not an accurate notation, please replace it with "$! { Mobile }"!="" Description: #if ($mobile)This notation can only work on nullOther words #if ($mobile)or Receiver_mobile =:mobile #end If The mobile parameter is NULL, then SQL does not stitch the text inside However, if the "" (empty string) is passed in, the text will be stitched(Note: Of course, you can in the manager class will "" first turn to null, not afraid of trouble) if you have to judge null and empty, how to do it? should be written like this: #if ("$!{ Mobile} "! =" ") or Receiver_mobile =:mobile #end其中 $! {Mobile} is a VTL (quiet reference quiet Reference Notation) http://velocity.apache.org/engine/devel/user-guide.html# Quietreferencenotation The official documentation describes this:If mobile variable is null, or is not assigned a value,Direct use ${mobile}, the interface will display the variable name, i.e. (${mobile}) and with $! {Mobile}, blank text is displayed This wiki is worth a look.Http://wiki.apache.org/velocity/CheckingForNull

Velocity determines if the variable is not empty or null

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.