/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hello;
/**
*
* @author iridiumcao@gmail.com
*
*/
public class Functions {
public static String reverse(String text) {
return new StringBuffer(text).reverse().toString();
}
public static int getStringSize(String string) {
return string.length();
}
}
这个文件改写自 Tomcat 的例子,故保留这段 License 信息。
这里的方法必须是 public static 的,否者 EL 无法调用。
如果写接受多个参数的方法,也是可以的,调用的时候传入进去就行了。返回类型也不一定要是 String, 这里就用了 int.