zoukankan      html  css  js  c++  java
  • Struts2超链接

    本文涉及到的知识:Struts2超链接的使用、Struts遍历List、${pageContext.request.contextPath} 不能出现在Struts2标签中。

    Struts2中的<s:url>标签可以生成一个URL 地址,而且可以内嵌<s:param>标签,为URL指定请求参数。

    具体属性有:

    action:可选属性,指定生成的 URL 地址的 Action,如果 action 属性未指定,则需要使用 value 作为 URL。

    value:可选属性,指定生成的 URL 地址,若 value 属性未指定,则需要指定 action 属性。

    method:可选属性,指定 Action 的方法,当用 action 属性生成 URL 时,使用该属性指定链接到 Action 的特定方法。

    namespace:可选属性,指定名字空间,当用 action 生成 URL 时,使用该属性指定 Action 的 namespace。

    具体例子:

            <s:iterator value="suList" id="column">
                <tr>
                    <td><s:property value="sid" /></td>
                    <td><s:property value="sname" /></td>
                    <td><s:property value="ssex" /></td>
                    <td><s:property value="sdept" /></td>
                    <!-- 生成URL -->
                    <s:url id="url" action="/student!deleteStudent.action">
                        <s:param name="sid">
                            <s:property value="sid" />
                        </s:param>
                    </s:url>
                    <!-- 应用生成的URL -->
                    <td><s:a href="%{url}">删除</s:a>
                </tr>
            </s:iterator>

    看下效果:

    最后想要说的是,${pageContext.request.contextPath} 不能出现在action中,实际上${pageContext.request.contextPath}不能出现在任何的Structs2标签中。

    在Struts2标签中添加了${pageContext.request.contextPath}后,ecplise报错!

  • 相关阅读:
    洛谷P2216 理想的正方形
    洛谷P2698 花盆Flowerpot【单调队列】
    洛谷P2178 品酒大会【后缀数组】【单调栈】
    洛谷P2463 Sandy的卡片【后缀数组】【二分】
    PAT甲1038 Recover the smallest number
    PAT甲1101 Quick Sort
    PAT甲1031 Hello World for U【字符串】
    PAT甲1005 Spell it right【字符串】
    django_logging
    django_session
  • 原文地址:https://www.cnblogs.com/dichuan/p/7967990.html
Copyright © 2011-2022 走看看