Page usage:
<S: bean name = "com. hwtt. RBT. user. bean. cutstringbean "id =" cutstring "> <s: Param name =" str "value =" singername "/> <s: param name = "hold" value = "3"/> <s: property value = "formatstr"/> </S: bean>
Tool class:
Public class cutstringbean {private string STR; // The Private int hold of the string to be formatted; // The length of the private string end retained; // The end character private string formatstr; // formatted string Private Static final string end = ".. "; Public cutstringbean () {} Public String getstr () {return STR;} public void setstr (string Str) {This. STR = STR;} public int gethold () {return hold;} public void sethold (INT hold) {This. hold = hold;} public St Ring getend () {return end;} public void setend (string end) {This. end = end;} Public String getformatstr () {formatstr = get1_str (STR, hold, end); Return formatstr;} public void setformatstr (string formatstr) {This. formatstr = formatstr;}/*** shorten the string to the specified length, and end with the ending character ** @ Param Str * @ Param hold keep length * @ Param end string, if it is null, it is ".. "* @ return string */Public String get1_str (string STR, int H Old, string end) {If (STR = NULL | hold <1) Return ""; STR = Str. trim (); If (hold> Str. length () return STR; // int length = (hold % 2 )! = 0? Hold-1: hold; end = END = NULL? End: end; int abc123size = 0; // number and letter count if (Str. length ()> hold) {for (INT I = 0; I