Equivalent of TagUtils.getInstance().lookup() Struts1 in Struts 2

南楼画角 提交于 2019-12-24 06:04:07

问题


I have this function in Struts 1:

/*
 * (non-Javadoc)
 * 
 * @see org.apache.struts.taglib.bean.WriteTag#doStartTag()
 */
public int doStartTag() throws JspException {

    Carac carac = (Carac) TagUtils.getInstance().lookup(pageContext, name, property, scope);
    // Code here
    return SKIP_BODY;
}

and I am trying to create the same tag in Struts 2 but don't know what's the purpose of this:

TagUtils.getInstance().lookup()

回答1:


I found a solution to get my object from the view to the tag in struts 2 :

my tag :

<%@ taglib uri="wells/taglib/produit" prefix="produit"%>

         <produit:produitPhoto prod="row" />

Here is how t can get it:

  getStack().findValue(this.prod, Produit.class); // return Object Produit

Ref : Class TagUtils




回答2:


Precisely what the documentation says: it returns the named bean's property from the provided scope.



来源:https://stackoverflow.com/questions/14056722/equivalent-of-tagutils-getinstance-lookup-struts1-in-struts-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!