| <diego:with object="${Man}"> <diego:output property="name"/> </diego:with> |
| <diego:with object="${people}"> <!--表示取得一个对象--> <diego:withCollection property="men"> <!--表示取得对象里的一个属性,这个属性是个 Collection,Collection里添加了许多man,每个man有名字和年龄--> <diego:output property="name"/> <!--取得name属性并显示--> </diego:withCollection> </diego:with> |
| import org.apache.commons.beanutils.PropertyUtils; ...... property = PropertyUtils.getProperty(currentClass, propertyName); |
| package diegoyun; import java.io.IOException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.BodyTagSupport; import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager; /** * @author chenys */ public class WithTag extends BodyTagSupport { private Object value = null; private Object output = null; public void setOutput(Object output) { this.output = output; } public Object getValue() { return value; } public void setValue(Object value)throws JspException { this.value = ExpressionEvaluatorManager.evaluate("value", value.toString(), Object.class, this, pageContext); } public int doStartTag() { return EVAL_BODY_INCLUDE; } public int doEndTag()throws JspException { try { pageContext.getOut().print(output); } catch (IOException e) { throw new JspException(e); } return EVAL_PAGE; } } |
|||
| 共3页: 上一页 1 [2] [3] 下一页 | |||
![]() |