Rumah > hujung hadapan web > html tutorial > 如何在jsp页面中包含另一个jsp页面_html/css_WEB-ITnose

如何在jsp页面中包含另一个jsp页面_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-06-24 11:16:16
asal
2092 orang telah melayarinya

我想在一个jsp页面中包含另一个在同一目录下的jsp页面,使用的语句为

但是Myeclipse报错

错误信息:
Multiple annotations found at this line:
- Duplicate local variable 
 basePath
- Duplicate local variable path
- Duplicate local variable 
 basePath
- Duplicate local variable path


回复讨论(解决方案)

代码问题,有些变量定义不能在2个文件中都有

我把代码贴上

<%@ 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}栏目
Salin selepas log masuk
<%@ include file="/admin/pagination.jsp"%>

这是第一个jsp,第75行有错 我换了个文件夹就是可以…… 不知道为什么

pagination.jsp里面有
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";

吗,如果有要删除

写错了,用include标签

错误已经查出,因为我使用的是MyEclipse,所以新建页面的时候回自动添加一些东西,其中包括这个东西。去掉之后就好了
6楼正解

<%    String path = request.getContextPath();    String basePath = request.getScheme() + "://"            + request.getServerName() + ":" + request.getServerPort()            + path + "/";%>
Salin selepas log masuk

这段删除!

Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan