學慣用jsp:include標籤,出現了一個錯誤

來源:互聯網
上載者:User
java.io.IOException: Stream closed org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:202) org.apache.jasper.runtime.JspWriterImpl.clearBuffer(JspWriterImpl.java:157) org.apache.jsp.WEB_002dINF.pages.tilestest.main_jsp._jspService(main_jsp.java:76) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069) org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274) org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012) org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345) org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:582) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:260) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
以下是相關檔案:
---------------------main.jsp----------------------------
<table width="100%">
<tr>
 <td width="50%" valign="top">
 <jsp:include page="/sub1.do"/>
 </td>
</tr>
<tr>
 <td><jsp:include page="/sub2.do"/></td>
</tr>
</table>
--------------struts-config.xml------------------------
<action-mappings>
   <action path="/tilestest" forward="/WEB-INF/pages/tilestest/main.jsp"/>
   <action path="/sub1" forward="testTilesSub1"/>
   <action path="/sub2" forward="/WEB-INF/pages/tilestest/sub2.jsp"/>
</action-mappings>
 <plug-in className="org.apache.struts.tiles.TilesPlugin">
  <set-property property="definitions-config" value="/WEB-INF/struts/tiles-defs.xml"/>
    <set-property property="moduleAware" value="true"/>
    <set-property property="definitions-parser-validate" value="true"/>
 </plug-in>
--------------tiles-defs.xml----------------------------------
<tiles-definitions>
  <definition name="baseDef" path="/baselayout.jsp">
 <put name="title" value="baseDef.title"/>
 <put name="header" value="/WEB-INF/pages/titles/header.jsp"/>
 <put name="body" value="/WEB-INF/pages/titles/body.jsp"/>
 <put name="footer" value="/WEB-INF/pages/titles/footer.jsp"/>
  </definition> 
  <definition name="testTilesSub1" extends="baseDef">
    <put name="header" value="/WEB-INF/pages/tilestest/sub1.jsp"/>
  </definition>
  <definition name="testTilesSub2" extends="baseDef">
    <put name="header" value="/WEB-INF/pages/tiletest/sub2.jsp"/>
  </definition> 
</tiles-definitions>
sub1.jsp和sub2.jsp裡面都只有顯示的文字,如slkdjflksdflakdsflasd
請注意struts-config.xml中sub1和sub2的forward不一樣,用sub1的時候就會出現以上的錯誤。
錯誤解決方案見地址:http://mail-archives.apache.org/mod_mbox/tomcat-dev/200307.mbox/%3C20030709224018.7289.qmail@nagoya.betaversion.org%3E
和http://issues.apache.org/struts/browse/STR-2969
本人的理解:由於我在tiles-defs.xml中用了defination的extends屬性,所以會出現以上錯誤,後來我沒用extends,改用了path屬性,<definition name="testTilesSub1" path="/WEB-INF/pages/tilestest/sub1.jsp"/>這樣就可以了

 

相關文章

聯繫我們

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