jsp頁面中某個src,如某個iframe的src,應該填寫什么?可以是html、jsp、servlet、action嗎?是如何加載的?


jsp頁面中某個src,如某個iframe的src,應該填寫什么?可以是html、jsp、servlet、action嗎?是如何加載的?

如有個test工程,其某個jsp中有個iframe,代碼如下:

<div class="tc1" style="padding-left: 10px">
      <iframe src="${contextpath}/main/getIframeJsp" width="220" height="120px" marginwidth="1" marginheight="1" name="test" id="test" border="0" frameborder="0"></iframe>
</div>

iframe的src為:${contextpath}/main,完整鏈接為http://127.0.0.1:8080/test/main/getIframeJsp

===1可以是html 2可以是其他工程的html==

參考鏈接:http://www.w3school.com.cn/tags/att_iframe_src.asp

src 屬性規定在 iframe 中顯示的文檔的 URL。

 

規定顯示在 iframe 中的文檔的地址。

可能的值:

  • 絕對 URL - 指向其他站點(比如 src="www.example.com/index.html")
  • 相對 URL - 指向站點內的文件(比如 src="index.html")

===可以是本工程或者其他工程的,action、servlet==

參考鏈接:http://zhidao.baidu.com/link?url=SgvyO2Hj2b9AQbSmRmOPspYLMNqw_6XpiQY2VwiYLj8yG08dkOk-l4HF7A7nB9ZeSRGsuZDjJMvp5Aw4RuAVd3YIrb0xhQfXUF9vj55sbg7

 

問:  iframe中的src能否是servlet,再將servlet跳向的jsp顯示在iframe中?

答:可以的。
設置iframe的src=‘xxxxx / yyy.do’,在對應servlet中,類似下面寫法跳轉:request.getRequestDispatcher("/a/b.jsp").forward(request,response);

 

===總結

可以理解為,src是一個url請求,如這個:<div class="tc1" style="padding-left: 10px">
      <iframe src="${contextpath}/main/getIframeJsp" width="220" height="120px" marginwidth="1" marginheight="1" name="test" id="test" border="0" frameborder="0"></iframe>
</div>

src是http://127.0.0.1:8080/test/main/getIframeJsp,其執行的過程跟在瀏覽器中輸入http://127.0.0.1:8080/test/main/getIframeJsp的執行過程一樣,執行test工程mainAction類的getIframeJsp方法,並將執行結果在iframe位置顯示。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM