当前位置:编程学习 > JSP >>

为什么我的 <%@ include file="Buy.jsp" %>这一行一直出现错误,如果改成<jsp:include>标签的话就没有了!

错误为:Multiple annotations found at this line: - Duplicate local variable path - Duplicate local variable 应该是路径的问题,可是怎么解决啊??我要用为什么我的 <%@ include file="Buy.jsp" %> 代码如下:<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <jsp:useBean id="cart" scope="session" class="com.cn.select.select"></jsp:useBean> <% 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>My JSP 'conform.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> <jsp:setProperty property="item" name="cart" value="<%=request.getParameter("item")%>"/> <jsp:setProperty property="submit" name="cart" value="<%=request.getParameter("submit")%>"/> <% cart.processRequest(); %> <font size=4 color="#cc0000"> <br>您选择了如下商品: <br> <ol> <% String[] items=cart.getItems(); for(int i=0;i<items.length;i++) { String str=new String(items[i].getBytes("iso-8859-1"),"utf-8"); %> <li><%=str%></li> <% } %> </ol> </font> </body> <jsp:include flush="true" page="Buy.jsp"></jsp:include> <%@ include file="Buy.jsp" %> </html> 工程的目录结构如下:
追问:head.css文件?这个文件在哪啊?<%@page contentType="text/html;charset=gb2312"%>
这句话应该只是说了编码方式吧?加它和<%@include file="relativeURL"%>的路径是不是没关系啊?我看错误提示的意思好像是相对路径中找不到Buy.jsp文件啊!怎么就跟编码方式扯到一块了呢?是不是应该把路径改一下啊?已经贴上去了!!
答案:<%@include file="relativeURL"%>
include 指令为静态包含。 所包含的文件,也必须设置 contentType 或 pageEncoding 
所以,要在
head.css文件开头处中加入
<%@page contentType="text/html;charset=gb2312"%>
或者<%@page pageEncoding="gb2312"%>
其他:静态包含可以包含其它格式文件  比如说要包含一段文字 就可以在文件中只写一段文字  把后缀名命为.jspf 你的问题肯定是静态包含的jsp文件内部格式不对 找了半天怎么没看见你Buy.jsp的原代码? 可否拿来看看 。。。 一个是静态的,可以加入静态页面,另一个可以加入动态页面,(那是jsp里的动作标记)
代码没顾得上看,不知道正确否 

上一个:我做了一个JSP测试页面,但是怎么调试都不行,大侠们帮忙看一下,代码如下:
下一个:jsp中怎么实现 for循环中的div的不同命名,比如名称后加循环变量i。该怎么写?在线等。

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,