将字符串变量传递给struts标记

时间:2012-05-19 09:33:51

标签: struts

我想将字符串变量传递给struts标记。

alert('<bean:message key="${result}"/>');

此标记负责从ApplicationResources.properties中提取消息。结果包含此消息的密钥。系统尝试使用相同的结果字符串本身而不是其内容。这是我得到的错误。

“缺少关键字”$ {result}“

的消息

我看到这个问题而且我有了一个想法,但问题仍然存在。 Variable in an attribute in Struts custom tag

我的应用程序基于struts。

我使用这样的东西,但我觉得它丑陋而且很臭

    if(result == 'a.b.c' )
        alert('<bean:message key="a.b.c"/>');
    else if(result == 'a.b.c' )
        alert('<bean:message key="a.b.d"/>');
    else if(result == 'a.b.d' )
        alert('<bean:message key="a.b.d"/>');

1 个答案:

答案 0 :(得分:0)

请尝试以下方法:

alert('<bean:message name="result"/>');

http://struts.apache.org/1.2.x/userGuide/struts-bean.html#message