在超链接点击后,在当前jsp页面中显示另一个jsp内容 [英] Display another jsp content in current jsp page upon a hyperlink click

查看:235
本文介绍了在超链接点击后,在当前jsp页面中显示另一个jsp内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于Web的应用程序,在页面左侧有两个超链接,我在寻找的是当我点击一个超链接时,它应该加载另一个.jsp的内容,将它显示在present.jsp上,如果我点击下一个超链接,它应该对present.jsp上的third.jsp执行相同的操作。



我在stackoverflow上找到了如下内容: -



javascript--

  function showItem(url){
$('#right-pane')。load(url);

}

link - <一个href =showItem('another.jsp)> item 1



其中right-pane是div标签的id,我希望另一个jsp内容显示。

 < div id =right-panestyle =position:absolute; width:988px; height:649px; z-index:2; left:193px; top:4px> 

但是,当我点击第1项时,资源(/test1/showItem(another.jsp'))不可用。



我使用apache tomcat作为服务器。



感谢您,
Arshad

解决方案

添加类别或ID您的链接

 < a href ='another.jspclass =link1> item 1< / a> 

添加到您的标题中:

<$ p $()。$($)$ $ $ $($)$($)$($)$($)
var url = $(this).attr(href);
$('#right-pane')。load(url);
});
}) ;

试着改变这个< script type =text / javascriptsrc = jquery.js> line to

 < script src =http:// ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.jstype =text / javascript>< / script> 

在ie9中试用并测试过:

 <!DOCTYPE html> 
< html>
< head>
< meta charset =utf-8>
< title> title< / title>
< script src =http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.jstype =text / javascript>< / script>
< script>
$(document).ready(function(){
$(。link1)。click(function(event){
event.preventDefault();
var url = $(this).attr(href);

$('#right-pane')。load(url,function(data){
console.log(data) ;
});
console.log(url);
});
});
< / script>
< / head>
< body>
< div id =layer5class =style2style =position:absolute; width:79px; height:17px; z-index:1; left:11px; top:15px>< a href =test2.htmlclass =link1> item 1< / a>< / div>
< div id =right-panestyle =position:absolute; width:988px; height:649px; z-index:2; left:193px; top:4px>< / div>
< / body>
< / html>


I am developing a web based application in which i have two hyperlinks in the left side of the page, and what i'm looking for is that when i click on the one hyperlink it should load the content of another.jsp and display it over present.jsp and if I click next hyperlink it should do the same for third.jsp over present.jsp .

I found something on stackoverflow like:-

javascript--

    function showItem(url) {
$('#right-pane').load(url);

}

link--< a href="showItem('another.jsp)">item 1

where "right-pane" is the id of div tag where i want the another jsp content to be displayed.

< div id="right-pane" style="position: absolute; width: 988px; height: 649px; z-index: 2; left: 193px; top: 4px">

< /div>

But when i am clicking on item 1 its saying-- The requested resource (/test1/showItem('another.jsp')) is not available.

I am using apache tomcat as a server.

Thanks, Arshad

解决方案

add a class or id t your link

 < a href="'another.jsp" class="link1">item 1</a>

Add this to your header:

$(document).ready(function() {
    $(".link1").click(function(event){
       event.preventDefault();
       var url =$(this).attr("href");
       $('#right-pane').load(url);
    });
});

try change this<script type="text/javascript" src="jquery.js"> line to

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

tryed and tested this in ie9:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>title</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
        <script>
            $(document).ready(function() {
    $(".link1").click(function(event){
       event.preventDefault();
       var url =$(this).attr("href");

        $('#right-pane').load(url, function(data) {
        console.log(data);
    });
       console.log(url);
    });
});
        </script>
    </head>
    <body>
        <div id="layer5" class="style2" style="position: absolute; width: 79px; height: 17px; z-index: 1; left: 11px; top: 15px"><a href="test2.html" class="link1">item 1</a></div> 
        <div id="right-pane" style="position: absolute; width: 988px; height: 649px; z-index: 2; left: 193px; top: 4px"></div>
    </body>
</html>

这篇关于在超链接点击后,在当前jsp页面中显示另一个jsp内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆