<%-- --%> //comment
${1 + 2} //add
${3 div 4} //divide
${10%4} //mode
${10 mod 4}
${(1==2) ? 3 : 4} //judge
${'a' < 'b'} //boolean
//implicate function
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
${fn:escapeXml(param["foo"])} 提取url参数 foo 并用taglib fn中的 escapeXml进行escape
${fn:escapeXml(header["host"])} 提取http header 中的 host字段
${fn:escapeXml(header["user-agent"])} 提取user agent字段
反转字符串
public static String reverse( String text ) {
return new StringBuilder( text ).reverse().toString();
}
元音字母个数
public static int numVowels( String text ) {
String vowels = "aeiouAEIOU";
int result = 0;
for( int i = 0; i < text.length(); i++ ) {
if( vowels.indexOf( text.charAt( i ) ) != -1 ) {
result++;
}
}
return result;
}
大写化
public static String caps( String text ) {
return text.toUpperCase(Locale.ENGLISH);
}