简体   繁体   中英

JSP include directive not working with struts tag

I have a section which gets displayed using the struts tag below followed by a jsp include

<div>
     <span>Title</span>
    <s:action name="content" namespace="/tempcontent" executeResult="true" flush="false">
        <s:param name="shortName">qr</s:param>
        <s:param name="maxResults">3</s:param>
        <s:param name="template">/jsp/peps/chSection.jsp</s:param>
    </s:action>
</div>

<div>
   <%@include file="/jsp/ratings/includes/screening.jsp" %>
</div>

Here I am not able to render the JSP using the include directive. If I remove the section containing struts tag It gets included properly. This seems to be strange to me. Please help.

I am not able to render the JSP

Have you included the Struts tags declaration ?

<%@ taglib prefix="s" uri="/struts-tags" %>

Also remember the big differences between a static <%@include directive, a dynamic <jsp:include/> action, or even better, use a Struts-specific <s:include /> tag.

I have solved that with the help of Velocity.I have used velocity template for the view. Now its able to include the other JSPs in it.

<div>
 <span>Title</span>
<s:action name="content" namespace="/tempcontent" executeResult="true" flush="false">
    <s:param name="shortName">qr</s:param>
    <s:param name="maxResults">3</s:param>
    <s:param name="velTemplate">chPepSection.vm</s:param>
    <s:param name="template">/jsp/peps/chSection.jsp</s:param>
</s:action>
</div>

<div>
   <%@include file="/jsp/ratings/includes/screening.jsp" %>
</div>

I am using velocityEngine to merge the model i am getting for the view with the velocity template.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM