zoukankan      html  css  js  c++  java
  • JSP :使用<%@include%>报Duplicate local variable path 错误

    今天在做商城页面,遇到问题:

    <%@include file="menu.jsp" %>

    错误提示:

    Multiple annotations found at this line:
     - Duplicate local variable path
     - Duplicate local variable 
      basePath

    重复变量,

    改成: <jsp:include page="menu.jsp"> 也不行

    查资料:

    因为<%@include%>引进的是代码,把代码包含进来,而新进JSP时,会默认生成

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

    <base href="<%=basePath%>">

    这二句代码,所以用<%@include%>引进页面是就报重复变量 basePath

    解决方法,把要引进页面的重复的句子去掉就行,

    另外:

    查询到 <%@ include file=""%>与<jsp:include page=""/> 的区别: 

    一、执行时间上: 
    <%@ include file=”relativeURI”%> 是在翻译阶段执行 
    <jsp:include page=”relativeURI” flush=”true” /> 在请求处理阶段执行。 
    二、二:引入内容的不同: 
    <%@ include file=”relativeURI”%> 引入静态文本(html,jsp),在JSP页面被转化成servlet之前和它融和到一起。 
    <jsp:include page=”relativeURI” flush=”true” /> 引入执行页面或servlet所生成的应答文本。

    翻译:  JSP容器负责将jsp页面转化成servlet,并编译这个servlet。

  • 相关阅读:
    QT多个UI文件加入一个项目
    【Go语言】学习资料
    MVC如何在Pipeline中接管请求的?
    ASP.NET MVC路由(5)
    C# dll 事件执行 js 回调函数
    初识Identity
    SpringMVC拦截器
    UrlRouting的理解
    ASP.NET MVC路由
    ASP.NET MVC Module
  • 原文地址:https://www.cnblogs.com/pikaqiucode/p/8227468.html
Copyright © 2011-2022 走看看