I have index.jsp which contains header.jspf,main content and footer jspf. I am using s include to include header and footer jspf.
My header jspf contains surl tags with param values in it. I have included s tagslib in it.
My index.jsp/header.jspf both contains the taglib declaration.
<%@taglib prefix="s" uri="/struts-tags"%>
My header action file looks like below,
public class Header extends ActionSupport {
public Header() {
}
@Override
public String execute() throws Exception {
return SUCCESS ;
}
}
my struts xml declaration is as below
<action name="Header" class="org.mypackage.mypackagename.Header" method="execute" >
<result name="SUCCESS">/WEB-INF/views/header/header.jspf</result>
<result name="error">/WEB-INF/views/error-page.jsp</result>
</action>
In the index jsp, I m including the jspf as ,
<s:include value="/WEB-INF/views/header/header.jspf"/>
but for some reasons this never works, it shows the source code/broken html in header section. I also have struts 2 html tags in index.jsp which seems to work perfectly fine.
The same set up works for child pages which are not welcome page.
Do I need to use prepare interface to include header jspf. My footer jspf does not contain any struts tag so probably it seems to work fine.
I am unable to see whats going on here so need some other thoughts.
Index jsp is declared as welcomme page in web xml.
If
Head
is just a JSP Fragment, and your real, full page is Index.jsp, then you should map that page to an Action, not the fragment itself:Index.jsp
Struts.xml
Note that
"SUCCESS"
is wrong: it should be"success"
, orAction.SUCCESS
(a constant, also in ActionSupport, that is mapped to"success"
).