在Struts的jsp页面中包含jsp片段

时间:2016-04-18 08:26:43

标签: jsp

我正在编写一个Struts2应用程序。

我想创建一个header.jspf片段来调用一个动作,但也会包含在其他jsp页面中。在包含时,主jsp页面将header.jspf中的<%@taglib uri="/struts-tags" prefix="s" %>显示为普通文本。

主要的jsp如下:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html>
<html>`enter code here`
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:property value="title"/></title>
<s:include  value="/WEB-INF/content/jspf/homeheader.jspf" />
</head>
<body>
<div>
<div>
<s:action name="allcategories" var="cat" ></s:action>
<s:iterator value="#cat.categories">
<s:property  value="name"/>
</s:iterator>
<s:a action="showcatreg" >input category</s:a>
</div>
</div>
</body>
</html>

这是header.jspf

<%@ taglib prefix="s" uri="/struts-tags"%>
<div id="header">
<h1>BOOKSELLER</h1>
<div>
<ul>
<li><a><img src="" alt="home"/></a></li>
<li><a href="">Contact Us</a></li>
<li><a href="">Help</a></li>
</ul>
<ul>
<li><a href="">Wishlist</a></li>
<li><a href="<s:url action="showadmin"/>">click here</a> </li>
</ul>
</div>
<img src="" alt="bookseller logo"/>
<p><input type="search" value="Search Items"/></p>
<h2>Welcome to the home of books online</h2>
<ul>
<li>Sign in</li>
<li>New Here? Register</li>
<li>Contact Us</li>
</ul>


</div>

屏幕截图中的结果:

enter image description here

0 个答案:

没有答案
相关问题