問題
看這個JSP例子
<%
String name=
request
%>
<c:out value=
許多JSTL標簽支持El表達式
下面這個例子
package diegoyun;
import javax
import javax
import mons
import org
public class SetVarTag extends TagSupport
{
private Object value = null;
private String property = null;
private String var = null;
public void setVar(String var)
{
this
}
public void setProperty(String property)
{
this
}
public void setValue(Object value)throws JspException{
this
}
public int doEndTag() throws JspException{
Object propertyValue = null;
try{
propertyValue = PropertyUtils
}
catch (Exception e) {
throw new JspException(e);
}
pageContext
return EVAL_PAGE;
}
}
編寫TLD
<!
<tag>
<name>set</name>
<tag
<body
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
編寫JSP
<%@ page language=
<%@ page import=
<%@ taglib uri=
<%@ taglib uri=
<html>
<body bgcolor=
<%
Man man = new Man();
man
request
%>
Get value from request and set it
<diego:set value=
now use OutTag of jstl taglib to get the name:<br>
value is : <c:out value=
</body>
</html>
運行
Get value from request and set it
now use OutTag of jstl taglib to get the name:
value is : diego
結束語
和JSTL交互是非常有用的技術
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19434.html