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

來源:互聯網
上載者:User

標籤:div   理解   瀏覽器   padding   tin   載入   dao   path   相對   

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位置顯示。

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.