如何在jsp页面中包含另一个jsp页面

一叶知秋Autumn 2016-06-03 09:08:49
我想在一个jsp页面中包含另一个在同一目录下的jsp页面,使用的语句为<%@ include file="pagination.jsp"%>

但是Myeclipse报错

错误信息:
Multiple annotations found at this line:
- Duplicate local variable
basePath
- Duplicate local variable path
- Duplicate local variable
basePath
- Duplicate local variable path
...全文
399 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lancer01 2016-06-04
  • 打赏
  • 举报
回复
写错了,用include标签
孟子E章 2016-06-04
  • 打赏
  • 举报
回复
pagination.jsp里面有 String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; 吗,如果有要删除
一叶知秋Autumn 2016-06-04
  • 打赏
  • 举报
回复
错误已经查出,因为我使用的是MyEclipse,所以新建页面的时候回自动添加一些东西,其中包括这个东西。去掉之后就好了 6楼正解

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
这段删除!
一叶知秋Autumn 2016-06-03
  • 打赏
  • 举报
回复
这是第一个jsp,第75行有错 我换了个文件夹就是可以…… 不知道为什么
一叶知秋Autumn 2016-06-03
  • 打赏
  • 举报
回复

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>博客栏目</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<style type="text/css">
body {
	background: url(image/projectBG.jpg);
}

.head {
	margin-top: 50px;
	text-align: center;
	font-size: 24px;
	color: #FF9933;
}

.head pre {
	font-weight: 900;
}

.blog {
	text-align: center;
	margin-top: 100px;
}

.blog a {
	color: red;
	font-size: 20px;
}
</style>

</head>

<body>
	<div class="head">
		<pre style="font-weight:900">${project}栏目</pre>
	</div>
	
	<div class="blog">
		<table border="1" align="center">
		<c:forEach items="${requestScope.list }" var="user">
			<tr>
				<td width="800"><a href="MessageServlet?status=PtoM&title=${user.title }" style="text-decoration:none">${user.title }</a></td>
			</tr>
		</c:forEach>
		</table>
	</div>
	
	<c:set var="currentPage" value="${currentPage }"/>
	<c:set var="cotalPage" value="${countPage }"/>
	<c:set var="cctionUrl" value="MessageServlet?status=ProjectBlog&project=${project }"/>
	
	<c:set var="urlParas" value="" />
<!-- 	<%@ include file="pagination.jsp"%> -->
	<%@ include file="/admin/pagination.jsp"%>
</body>
</html>

一叶知秋Autumn 2016-06-03
  • 打赏
  • 举报
回复
我把代码贴上
孟子E章 2016-06-03
  • 打赏
  • 举报
回复
代码问题,有些变量定义不能在2个文件中都有

61,115

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧