日期:2014-05-17  浏览次数:20622 次

引用一个jsp文件 报错 菜鸟问题 大家来捡分了……
我写了
<%@include file="TestIncludeHead.jsp" %>
这个 可是报错
Multiple annotations found at this line:
- Duplicate local variable basePath
- Duplicate local variable path
Java code

这事怎么回事?
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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>
  <%@include file="TestIncludeHead.jsp" %>
    <base href="<%=basePath%>">
    
    <title>My JSP 'TestIncledeFoot.jsp' starting page</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">
    -->

  </head>
  
  <body>
    This is my JSP page. <br>
  </body>
</html>



------解决方案--------------------
TestIncludeHead.jsp里的头文件和这个文件里的头文件重复了
------解决方案--------------------
HTML code

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>  <title>My JSP 'TestIncledeFoot.jsp' starting page</title> </head>  <body>  This is my JSP page. <br>  </body> </html>

------解决方案--------------------
探讨
怎么解决?总不能把
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
删了吧