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.