在Struts 2中等效于TagUtils.getInstance().lookup()Struts1 [英] Equivalent of TagUtils.getInstance().lookup() Struts1 in Struts 2

查看:372
本文介绍了在Struts 2中等效于TagUtils.getInstance().lookup()Struts1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Struts 1中具有此功能:

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;
}

并且我试图在Struts 2中创建相同的标签,但不知道这样做的目的是什么:

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()

推荐答案

我找到了一种解决方案,可将对象从视图中获取到struts 2中的标签:

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

我的标签:

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

         <produit:produitPhoto prod="row" />

这是怎么得到它的:

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

Ref: TagUtils类

这篇关于在Struts 2中等效于TagUtils.getInstance().lookup()Struts1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆