【问题标题】:Unable to set Window State to Exclusive in Struts2 Liferay Portlet无法在 Struts2 Liferay Portlet 中将窗口状态设置为独占
【发布时间】:2014-09-18 11:54:24
【问题描述】:

概述:将 struts2 web-appp 移植到 liferay struts2 6.2 portlet

问题:无法在struts2标签<s:url ..../>中将windowState设置为“独占”

说明:我需要在struts2标签<s:url ..../>中设置windowState为“Exclusive”。

我正在尝试以下选项,但无法将 url 的窗口状态设置为独占。

<s:url var="billingOverview" action="%{billingOverviewURL}"
       portletMode="view" portletUrlType="struts.portlet.action"
       windowState=<%=LiferayWindowState.EXCLUSIVE.toString()%> />

最初我得到了异常:“根据tld或属性windowState,不接受任何表达式”。我修改了struts2核心jar(struts2-core-2.3.7.jar)的“struts-tags.tld”文件,我在其中进行了以下更改以通过将 rtexprvalue 更改为 TRUE 来接受 windowState 标记中的表达式:

<attribute>
      <description><![CDATA[The resulting portlet window state]]></description>
      <name>windowState</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
</attribute>

如果我能对上述问题有所了解,那就太好了。提前致谢!

【问题讨论】:

    标签: java struts2 liferay portlet


    【解决方案1】:

    你不能在 Struts 标签中嵌套 scriptlet(&lt;%...%&gt;,你不应该在其他任何地方使用)。

    您需要在struts.xml中启用静态方法访问

    <constant name="struts.ognl.allowStaticMethodAccess" value="true" />
    

    然后使用以下语法引用 FQCN:

    改成:

    <s:url portletUrlType="struts.portlet.action"
              portletMode="view" 
                      var="billingOverview" 
                   action="%{billingOverviewURL}"   
              windowState="%{@com.liferay.portal.kernel.portlet.LiferayWindowState@EXCLUSIVE}" />
    

    更多关于the documentation

    【讨论】:

    • 不需要允许静态方法访问来获取静态字段。
    • @AleksandrM 总是被文档愚弄:OGNL supports accessing static properties as well as static methods. By default, Struts 2 is configured to disallow this--to enable OGNL's static **member** support you must set the struts.ognl.allowStaticMethodAccess constant to true via any of the Constant Configuration methods. 但我猜你是对的......不记得了,因为我几乎总是正确的,顺便说一句属性的名称建议你是对的:)
    • 我会试试这个,并会更新..thx 为您的回复:)
    • @AndreaLigios:我发现在struts.xml 中allowStaticMethodAccess 的值已经设置为true,如果我将它设置为false,其他网页数据就会变得不一致。尽管如此,我尝试将其设置为 false 并按照您上面提到的方式设置 windowState,但形成的 url 仍然是“正常的”,即p_p_state=normal。所以问题还是没有解决。
    • @TechieTalk :从游戏中忽略 allowStatichMethodAccess,它应该是无关紧要的(留给true)。您使用的是哪个版本的 Struts?你能用 url 发布生成的 HTML 吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多