Jsp tag file例子以及说明(4)
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
private boolean _jspx_meth_easy_005ffirstTag_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
throws java.lang.Throwable {
javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
// easy:firstTag
org.apache.jsp.tag.web.firstTag_tag _jspx_th_easy_005ffirstTag_005f0 = (new org.apache.jsp.tag.web.firstTag_tag());//构造tag类
_jsp_instancemanager.newInstance(_jspx_th_easy_005ffirstTag_005f0);
_jspx_th_easy_005ffirstTag_005f0.setJspContext(_jspx_page_context);
_jspx_th_easy_005ffirstTag_005f0.doTag();//开始执行dotTag方法,和标准的tag lib类似.
_jsp_instancemanager.destroyInstance(_jspx_th_easy_005ffirstTag_005f0);
return false;
}
例子2 在jsp引入tag file,并传递参数给tag file
encodeTagTest.jsp
[java]
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="easy" tagdir="/WEB-INF/tags" %>
//引入tag,传入参数input,值为"<br/> means changing line"
<easy:encode input="<br/> means changing line"/>
encode.tag
[java]
<%@ attribute name="input" required="true" %>
<%!
//定义方法
private String encodeHtmlTag(String tag) {
if (tag==null)
return null;
int length = tag.length();
StringBuffer encodedTag = new StringBuffer(2 * length);
for (int i=0; i<length; i++) {
char c = tag.charAt(i);
if (c=='<')
encodedTag.append("<");
else if (c=='>')
encodedTag.append(">");
else if (c=='&')
encodedTag.append("&");
else if (c=='"')
encodedTag.append(""");
else if (c==' ')
encodedTag.append(" ");
相关新闻>>
- 发表评论
-
- 最新评论 更多>>