没有显示在struts2中的url中添加参数

时间:2012-12-21 02:29:55

标签: java ajax url struts2 get

我在我试图去的页面的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>

正在显示的网址是

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

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

我不知道这是否有所作为,但我正在使用这个插件来进行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>

1 个答案:

答案 0 :(得分:2)

使用action标记并使用嵌套的param标记,请参阅下面的代码。

<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>