因为你的"value"是不固定的,直接用这个显示就行了啊<bean:write name="ActionForm" property="name" />干吗还要用<bean:message key="value" />

解决方案 »

  1.   

    我是要通过key的值调用.properties中的信息.不是要显示这个值.
      

  2.   

    我是通过<bean:message key="value" />调用.properties文件中的一些信息,如果key="1"就调用"你好!",如果key="2"就调用"再见!",现在这个key的值是不定的,要使用页面中一个变量<bean:write name="ActionForm" property="name" />,我就是走不知道这个变量要怎么加到key里面.
    不知道说清楚没有.
      

  3.   

    我觉得你在Action中使用ActionMessages来实现这样的功能会更好
      

  4.   

    谢谢大家的回复,我现在想知道怎么在<bean:message key="value" />中调用<bean:write name="ActionForm" property="name" />变量
      

  5.   

    在页面加入JAVA判断不就行了,然后你在控制层返回你需要的值
      

  6.   

    在ACTION中加用入request.setAttribute("name",ActionForm.getName());然后在页面用request.get不就行了,再把这个变量给key=<%=(String)request.getAttribute("name")%>
      

  7.   

    谢谢大家的回复!
    我本来是这样解决的 但是感觉有点乱 
    有没有直接用strut标签的做法。?
      

  8.   

    是啊,我也遇到和楼主一样的问题,我的意思也跟楼主一样,就是:既然使用标签就是为了不使用Scriptlet,那么当然希望通过标签嵌套来实现“无Scriptlet化”了。如果像 djpsunday(少壮且为风流事) 所说,方法当然行得通,但依然使用了Scriptlet。所以,问题还是没有得到解决,不过可以提供一个方法让楼主试一试,嵌套中使用JSP的EL可以吗?楼主如果尝试成功,请用短信告诉我一声,我周一回办公室也准备尝试一下。互相学习。
      

  9.   

    The Struts-EL tag library is a contributed library in the Struts distribution. It represents an integration of the Struts tag library with the JavaServer Pages Standard Tag Library, or at least the "expression evaluation" engine that is used by the JSTL.The base Struts tag library contains tags which rely on the evaluation of "rtexprvalue"s (runtime scriptlet expressions) to evaluate dynamic attribute values. For instance, to print a message from a properties file based on a resource key, you would use the bean:write tag, perhaps like this:
        <bean:message key='<%= stringvar %>'/>
        This assumes that stringvar exists as a JSP scripting variable. If you're using the Struts-EL library, the reference looks very similar, but slightly different, like this:
        <bean-el:message key="${stringvar}"/>
        If you want to know how to properly use the Struts-EL tag library, there are two important things you need to know:    * The Struts tag library
        * The JavaServer Pages Standard tag libraryOnce you understand how to use these two, consider Struts tag attribute values being evaluated the same way the JSTL tag attribute values are. Past that, there is very little else you need to know to effectively use the Struts-EL tag library.Although the Struts-EL tag library is a direct "port" of the tags from the Struts tag library, not all of the tags in the Struts tag library were implemented in the Struts-EL tag library. This was the case if it was clear that the functionality of a particular Struts tag could be entirely fulfilled by a tag in the JSTL. It is assumed that developers will want to use the Struts-EL tag library along with the JSTL, so it is reasonable to assume that they will use tags from the JSTL if they fill their needs.