ToGBKFuncs.java
package dgut.ke.el;
public class ToGBKFuncs {
public static String toGBK(String str ,String charset)
throws java.io.UnsupportedEncodingException
{
return new String(str.getBytes(charset),"GBK");
}
}
WEB-INF\tlds\myfuncs.tld
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptagliblibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<uri>/myfuncs</uri>
<function>
<name>toGBK</name>
<function-class>dgut.ke.el.ToGBKFuncs</function-class>
<function-signature>
java.lang.String toGBK(java.lang.String,java.lang.String)
</function-signature>
</function>
</taglib>
test.jsp
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="myfn" uri="/myfuncs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Tag</title>
</head>
<body>
欢迎你的到来 ${myfn:toGBK(param.username,"ISO8859-1")} !
</body>
</html>
posted on 2007-09-20 22:40
Ke 阅读(778)
评论(0) 编辑 收藏 所属分类:
tag