【问题标题】:Struts2 Div Ajax ReloadStruts2 Div Ajax 重新加载
【发布时间】:2011-10-23 03:22:58
【问题描述】:

我有一个简单的用例

    <div id="contentDiv">

            <!-- This does not work -->
            <div id="frmDiv">
                    <s:form action="..">
                            <s:a target="contentDiv" theme="ajax">Reload</s:a>
                    </s:form>
            </div>

            <!--This works -->
            <div id="listDiv">
                    <s:a target="frmDiv" theme="ajax" someaction >Click Me</s:a>
            </div>
    </div>

我注意到,当链接的目标位于同一目标内时,此 ajax 操作不起作用。而当链接的目标在 div 之外时,这可以按要求工作。

重新加载相同 div 或将其设置为 ajax 结果目标的任何解决方法。

我正在使用 struts 2.0.14

如果我使用按钮,这里也不是链接,这不起作用。任何解决方法将不胜感激。

【问题讨论】:

    标签: ajax html struts2 reload target


    【解决方案1】:

    只要有意义就使用 html。从长远来看,也使用 ajax witout 标签库可能是更快的方法。它们非常适合模板和简单的逻辑,但随着客户端需求的要求越来越高,它们很快就会失败。

    您应该升级应用程序,任何东西都不太可能会损坏并且您会获得一些新功能。您遇到的问题可能不存在。尚未对其进行测试,但标签库自该版本以来已进行了许多改进和修复。

    <a href="#first">link to first</a>
    <a href="#second">link to second</a>
    
    <!-- following weird ognl was used because you are at version 2.0.14, you should upgrade then I could have used the begin and end attributes, like in c:forEach-->
    <s:iterator value="(84).{ #this }" >
      <br/>
    </s:iterator>
    
    <div id="first">
     This is first.
    </div>
    
    <s:iterator value="(84).{ #this }" >
      <br/>
    </s:iterator>
    
    <div id="second">
     This is second
    </div>
    

    【讨论】:

      猜你喜欢
      • 2013-07-10
      • 2013-06-03
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      • 2015-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多