Cannot forward after response has been committed

來源:互聯網
上載者:User

Cannot forward after response has been committed

 

試圖在jsp頁面裡包含Action:

<c:import url="/friendlink.do?method=list"></c:import>
<jsp:include flush="true" page="friendlink.do"></jsp:include>

 

結果出現以上錯誤。

想想其實也很容易理解,Action的過程本身就是請求轉寄,而此時處理未完成頁面卻已輸出。

 

解決辦法一:使用bean:include 

 

<bean:include id="friendlink" page="/friendlink.do?method=list"/>

<bean:write name="friendlink" filter="false"/>

 

可以這樣理解,就是Action處理的結果被儲存到bean裡了,這裡只是輸出bean裡包含的內容,沒有涉及頁面轉寄和定向問題,所以不會有異常。

 

解決辦法二:使用tiles

 

tiles裡可以直接包含Action,配置方法和包含jsp時一樣。

 

解決辦法三:使用Ajax

 

Ajax就是被設計來從後台非同步發送請求和接收處理結果,所以必定能滿足這種需求。

 

解決辦法四:使用TAG

 

標籤的用法就不用說了,相當於不用Action而在頁面嵌入Java代碼。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.