1

我在尝试访问的页面的 url 中添加了一个参数,但在生成的 url 中没有显示,这是为什么呢?

这是我的jsp。

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<sj:head ajaxhistory = "true" ajaxcache="true" />
<script>

</script>
</head>
<body>
    <h5>Struts Jquery Ajax Integration</h5>

    <div id="resultContent"></div>


    <noscript>Please Turn On Javascript to make the full use of this site</noscript>

    <h4>Choose A task</h4>
    <ul>
        <s:url value="views/ajaxvalidation.jsp" var="ajaxvalidation" >
            <s:param name="menuId" value="1"/>
        </s:url>
        <li><sj:a targets="resultContent" href="%{ajaxvalidation}">Ajax Validation</sj:a></li>
    </ul>

    <div>
        <h6>Play A Music while You Navigate</h6>
        <audio src="x.mp3" controls>Your browser does not support the
            audio element.
        </audio>
    </div>
</body>
</html>

正在显示的 URL 是这个

http://localhost:8090/HelloStruts2/#resultContent=_sj_action_anchor_860825673resultContent

menuId我在url中添加的参数在哪里?

我不知道这是否会有所作为,但我正在为 jquery 使用这个插件。

struts2-jquery

生成的 HTML

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>





    <script type="text/javascript" src="/HelloStruts2/struts/js/base/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="/HelloStruts2/struts/js/base/jquery.ui.core.min.js?s2j=3.5.0"></script>
  <script type="text/javascript" src="/HelloStruts2/struts/js/plugins/jquery.subscribe.min.js"></script>
  <script type="text/javascript" src="/HelloStruts2/struts/js/plugins/jquery.ba-bbq.min.js"></script>

  <script type="text/javascript" src="/HelloStruts2/struts/js/struts2/jquery.struts2.min.js?s2j=3.5.0"></script>

<script type="text/javascript">
$(function() {
    jQuery.struts2_jquery.version="3.5.0";
    jQuery.scriptPath = "/HelloStruts2/struts/";
    jQuery.struts2_jquery.ajaxhistory = true;
    jQuery.ajaxSettings.traditional = true;

    jQuery.ajaxSetup ({
        cache: false
    });

    jQuery.struts2_jquery.require("js/struts2/jquery.ui.struts2.min.js");

    jQuery(window).trigger('hashchange');
});
</script>

        <link id="jquery_theme_link" rel="stylesheet" href="/HelloStruts2/struts/themes/smoothness/jquery-ui.css?s2j=3.5.0" type="text/css"/>

<script>

</script>
</head>
<body>
    <h5>Struts Jquery Ajax Integration By Kyel</h5>

    <div id="resultContent"></div>


    <noscript>Please Turn On Javascript to make the full use of this site</noscript>

    <h4>Choose A task</h4>
    <ul>



        <li><a id="anchor_2068827505" href="javascript:void(0)">Ajax Validation</a>
<script type='text/javascript'>
jQuery(document).ready(function () { 
    var options_anchor_2068827505 = {};
    options_anchor_2068827505.jqueryaction = "anchor";
    options_anchor_2068827505.id = "anchor_2068827505";
    options_anchor_2068827505.targets = "resultContent";
    options_anchor_2068827505.href = "views/ajaxvalidation.jsp";
    options_anchor_2068827505.hrefparameter = "menuId=1";

jQuery.struts2_jquery.bind(jQuery('#anchor_2068827505'),options_anchor_2068827505);

 });  
</script></li>




        <li><a id="anchor_1381525763" href="javascript:void(0)">Thank you JSP</a>
<script type='text/javascript'>
jQuery(document).ready(function () { 
    var options_anchor_1381525763 = {};
    options_anchor_1381525763.jqueryaction = "anchor";
    options_anchor_1381525763.id = "anchor_1381525763";
    options_anchor_1381525763.targets = "resultContent";
    options_anchor_1381525763.href = "views/thankyou.jsp";
    options_anchor_1381525763.hrefparameter = "menuId=2";

jQuery.struts2_jquery.bind(jQuery('#anchor_1381525763'),options_anchor_1381525763);

 });  
</script></li>
    </ul>

    <div>
        <h6>Play A Music while You Navigate</h6>
        <audio src="x.mp3" controls>Your browser does not support the
            audio element.
        </audio>
    </div>
</body>
4

1 回答 1

2

使用动作标签并使用嵌套参数标签见下面的代码。

<s:url id="login" action="admin/showProfile" var="profileUrl">
    <s:param name="user">Rais</s:param>
</s:url>

<a href='<s:property value="#profileUrl"/>'>
<s:property value="#profileUrl"/></a>
于 2012-12-21T03:41:14.443 回答