Only examples of front and back fields are displayed when key sensitive fields are hidden in jsp. jsp examples

Source: Internet
Author: User

Only examples of front and back fields are displayed when key sensitive fields are hidden in jsp. jsp examples

To write a jsp page today, you must hide the middle part of the field. Only the first and last digits are displayed. After searching, we found that most of the above fields are hidden, or the mobile phone number or ID card is hidden using regular expressions. In this case, the length of the field must be known in advance, and I do not want to know that the length only displays the first 3 digits and the last 4 digits.

No way. Who makes the length of the field I want to hide uncertain.

Solution: 1. If you know the field length, you can use a regular expression or the fn function in the jsp tag library.

Regular Expression

phone.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"); 152****4799idCard.replaceAll("(\\d{4})\\d{10}(\\w{4})","$1*****$2");4304*****7733 

Fn Function 

Copy codeThe Code is as follows:
$ {Fn: substring (item. mobile, 152)} ***** $ {fn: substring (item. mobile, 4799)} <br> *****

Copy codeThe Code is as follows:
$ {Fn: substring (item. idCard, 4304)} ***** $ {fn: substring (item. idCard, 7733)} <br> ****

2. If you do not know the field length, only the front part and the back part are displayed. You can only use fn.

Copy codeThe Code is as follows:
$ {Fn: substring (item. account, 0, 3)} ***** $ {fn: substring (item. account, fn: length (item. account)-4, (fn: length (item. account )))}

In this way, only the first three digits and the last four digits are displayed.

Only the first few digits are displayed on the post, and the last few digits are replaced by... ellipsis for long titles.

<C: if test = "$ {fn: length (itrm. fundName)> 10} ">$ {fn: substring (item. fundName, 0, 10 )}... </c: if> // a maximum of 10 digits are displayed. For more than 10 digits, use the ellipsis <c: if test = "$ {fn: length (item. fundName) <= 10} ">$ {item. fundName} </c: if>

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

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.