报错:Duplicate local variable

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了报错:Duplicate local variable相关的知识,希望对你有一定的参考价值。

代码:
<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*,
java.util.*"%>
<%@ page import="org.gjt.mm.mysql.Driver" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>删除</title>
</head>
<body>

<%!
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver" ;
public static final String DBURL = "jdbc:mysql://localhost:3306/votemanage" ;
public static final String DBUSER = "root" ;
public static final String DBPASS = "123" ;
%>
<%
Connection conn = null ;
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String name;

%>

%>
<%
String name=request.getParameter("name").trim();
try

Class.forName(DBDRIVER) ;
conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;

String sql="delete from vote where name="+name;
pstmt.executeUpdate(sql);
out.println("<font size=3 color=blue>正在删除……</font><meta http-equiv='refresh' content='2;url=main.jsp'>");
pstmt.close();
conn.close();

catch(Exception e)
System.out.println(e);

%>
</body>
</html>

报错:
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 28 in the jsp file: /web/del.jsp
Duplicate local variable name
25:
26: %>
27: <%
28: String name=request.getParameter("name").trim();
29: try
30:
31: Class.forName(DBDRIVER) ;
没有分了,跪求解答,感激不尽

报错:Duplicate local variable,是设置错误造成的,解决方法如下:

1、首先打开电脑,点击打开eclipse,在eclipse菜单栏里点击最后一个菜单“帮助下的Help文件”。点击菜单列表里,选择“Install New Software”项。

2、点击文本框右侧的“Add”按钮。

3、接着点击打开Archive打开一个路径或zip/jar文件,但可能会遇到“duplicate location”的错误提示信息。这时复制文本框中的位置。

4、然后点击“取消”按钮关闭当前弹出的窗口。

5、最后在“Install”窗口中的Work with文本框中直接粘贴刚刚复制的地址,结果出来了。

参考技术A ResultSet rs = null ;
String name;

这里有个 name
<%
String name=request.getParameter("name").trim();

这里也有一个,重名了。
根据自己的需要,要么删除其中一个 name,要么改个名字。使其不要重名本回答被提问者采纳

maven编译报错 was cached in the local repository 拉包失败

maven编译报错 was cached in the local repository 拉包失败

报错

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M3:repackage (default) on project otpweb: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M3:repackage failed: Plugin org.springframework.boot:spring-boot-maven-plugin:3.0.0-M3 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.springframework:spring-aop:jar:6.0.0-M4, org.springframework.boot:spring-boot-buildpack-platform:jar:3.0.0-M3: Failure to find org.springframework:spring-aop:jar:6.0.0-M4 in http://nexus3.msxf.com/repository/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus3 has elapsed or updates are forced -> [Help 1]

主要是因为Maven默认会使用本地缓存的库来编译工程,而上次下载的库失败导致的。

解决方法

共有三种方法,以下择一即可,推荐第二个

  1. 删除~/.m2/repository/对应目录或目录下的*.lastUpdated文件,然后再次运行maven命令
  2. maven命令后加-U,如mvn package -U 我是用这个解决的
  3. 在repository的release或者snapshots版本中新增updatePolicy属性,其中updatePolicy可以设置为”always”、”daily” (默认)、”interval:XXX” (分钟)或”never”
<repositories>
    <repository>
      <id>io.spring.repo.maven.release</id>
      <url>http://repo.spring.io/release/</url>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
      </releases>
      <snapshots><enabled>false</enabled></snapshots>
    </repository>
  </repositories>

以上是关于报错:Duplicate local variable的主要内容,如果未能解决你的问题,请参考以下文章

tomcat闪退无法启动 the catalina_home environment variable is not defined correctly this environment variab

Tomcat环境变量配置命令行报错:The JRE_HOME environment variable is not defined correctl This environment variab

linux 启动nacos报错_linux下启动Nacos报错解决:which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/

linux 启动nacos报错_linux下启动Nacos报错解决:which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/

mac brew install redis 报错

Mac Homebrew命令报错/usr/local/Homebrew/Library/Homebrew/version.rb:368:in `initialize’