2012-12-21 45 views
1

我在頁面的url中添加了一個參數,我試圖去但是在生成的url中它沒有被顯示,爲什麼?在struts2的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> 
+0

你能發佈生成的html代碼嗎? –

+0

@MohanaRaoSV我發佈了它,請檢查 – KyelJmD

+0

你究竟在哪裏看到這個URL「HelloStruts2 /#resultContent = _sj_action_anchor_860825673resultContent」? –

回答

2

使用行爲標籤和使用嵌套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> 
+0

我通過ajax請求加載頁面,如果我這樣做不會重新加載整個頁面? – KyelJmD