当前位置:Gxlcms > html代码 > 如何在jsp页面中包含另一个jsp页面_html/css_WEB-ITnose

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

时间:2021-07-01 10:21:17 帮助过:4人阅读

我想在一个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


回复讨论(解决方案)

代码问题,有些变量定义不能在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 + "/";%>博客栏目	
${project}栏目
${user.title }
<%@ 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 + "/";%>

这段删除!

人气教程排行