Java报错f cannot be resolved

Java新手 菜鸟一枚,请问大神 报错f cannot be resolved,怎么修改图片说明

2个回答

f 在wrw类中的main方法定义,其可见范围只在main方法中,所以后面addaction类中使用 f 就会报错:f cannot be resolved。

解决方法是通过匿名类的方式在main方法中添加Button的监听,示例代码如下:

import java.awt.*;
import java.awt.event.*;

public class Example {
    public static void main(String[] args) {
        Frame f = new Frame("ActionListener Example");
        final TextField tf = new TextField();
        tf.setBounds(50, 50, 150, 20);
        Button b = new Button("Click Here");
        b.setBounds(50, 100, 60, 30);

        b.addActionListener(new ActionListener() {  //这是关键代码
            public void actionPerformed(ActionEvent e) {
                tf.setText("Welcome to Here.");
            }
        });

        f.add(b);
        f.add(tf);
        f.setSize(400, 400);
        f.setLayout(null);
        f.setVisible(true);
    }
}

结果如下图:
图片说明

如果对您有帮助,请采纳答案好吗,谢谢!

fight_in_dl
战在春秋 回复sinat_39482179: 可以在addaction类中定义一个有参构造方法,然后将 f 作为参数传给 new addaction(f)。
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复战在春秋: 好的谢谢您,可是如果我不想用匿名内部类,想用创建类实现adtionlistener接口,那么在重写方法里f无法绑定吗![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/17.gif)
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复战在春秋: 好的谢谢您,可是如果我不想用匿名内部类,想用创建类实现adtionlistener接口,那么在重写方法里f无法绑定吗![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/17.gif)
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复战在春秋: 好的谢谢您,可是如果我不想用匿名内部类,想用创建类实现adtionlistener接口,那么在重写方法里f无法绑定吗![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/17.gif)
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复战在春秋: 好的谢谢您,可是如果我不想用匿名内部类,想用创建类实现adtionlistener接口,那么在重写方法里f无法绑定吗![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/17.gif)
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复战在春秋: 好的谢谢您,可是如果我不想用匿名内部类,想用创建类实现adtionlistener接口,那么在重写方法里f无法绑定吗![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/17.gif)
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复战在春秋: 好的谢谢您,可是如果我不想用匿名内部类,想用创建类实现adtionlistener接口,那么在重写方法里f无法绑定吗
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复战在春秋: 好的谢谢您,可是如果我不想用匿名内部类,想用创建类实现adtionlistener接口,那么在重写方法里f无法绑定吗
接近 3 年之前 回复

回答下你问楼上的问题,注意传递参数就可以了,用匿名内部类只是更简洁更方便,另外,最好去学一下匿名内部类。

sinat_39482179
sinat_39482179 回复嚣张的巡山夫: 好的谢谢您
接近 3 年之前 回复
sinat_39482179
sinat_39482179 回复嚣张的巡山夫: 好的谢谢您
接近 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
为什么这个程序报错 LocalDate cannot be resolved to a type?

代码是 ``` import java.time.LocalDate; public class TodayDate { public static void main(String[] args) { LocalDate today=LocalDate.now(); System.out.println(today); } } ``` 错误是 > Exception in thread "main" java.lang.Error: Unresolved compilation problems: LocalDate cannot be resolved to a type LocalDate cannot be resolved at TodayDate.main(TodayDate.java:5) 我用的是jdk11,eslipse也是18年9月的,应该不是版本问题吧?

一直显示import """cannot be resolved

报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fabricService' defined in ServletContext resource [/WEB-INF/classes/spring/applicationContext-servic e.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [textile.ssm.service.impl.FabricServiceImpl]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: The import com.ruanjian cannot be resolved name cannot be resolved to a variable。 我import 全部都删除了为什么还会跳出这个错误?

求助:myeclipse中出现错误一堆 R cannot be resolved to a variable

求助:myeclipse中出现错误一堆 R cannot be resolved to a variable 请求大佬们帮帮忙!! ![图片说明](https://img-ask.csdn.net/upload/201905/08/1557316761_351360.png) ![图片说明](https://img-ask.csdn.net/upload/201905/09/1557394144_264874.png) ![图片说明](https://img-ask.csdn.net/upload/201905/09/1557394154_594789.png) ![图片说明](https://img-ask.csdn.net/upload/201905/09/1557394165_151713.png) ![图片说明](https://img-ask.csdn.net/upload/201905/09/1557396740_896121.png)

报错位置提示Treeset cannot be resolved to a type!

报错位置ti'shiTreeset cannot be resolved to a type!![图片说明](https://img-ask.csdn.net/upload/201905/27/1558958371_291098.png)

报错显示Generic cannot be resolved to a type,代码要怎么修改?

```![图片说明](https://img-ask.csdn.net/upload/202003/15/1584268390_985021.png) 报错: Generic cannot be resolved to a type

在jsp文件中为什么已经引入了Arraylist包还一直显示list cannot be resolved to a variable?

![图片说明](https://img-ask.csdn.net/upload/202003/14/1584181884_453027.jpg) ![图片说明](https://img-ask.csdn.net/upload/202003/14/1584181914_23181.jpg)

jsp访问报错:Date cannot be resolved to a type

![图片说明](https://img-ask.csdn.net/upload/201706/29/1498719470_437994.png) 已经导入包了啊,为什么访问还报错?

java jxl excel导入数据库

java.lang.Error: Unresolved compilation problems: ServletActionContext cannot be resolved The type List is not generic; it cannot be parameterized with arguments <Integer> Syntax error, parameterized types are only available if source level is 5.0 ArrayList cannot be resolved to a type Syntax error, parameterized types are only available if source level is 5.0 The type List is not generic; it cannot be parameterized with arguments <String> Syntax error, parameterized types are only available if source level is 5.0 ArrayList cannot be resolved to a type Syntax error, parameterized types are only available if source level is 5.0 ActionContext cannot be resolved SysConstant cannot be resolved log cannot be resolved filePath cannot be resolved filePath cannot be resolved Constants cannot be resolved carInsModificationFacade cannot be resolved filePath cannot be resolved Constants cannot be resolved FacadeException cannot be resolved to a type e cannot be resolved e cannot be resolved The type List is not generic; it cannot be parameterized with arguments <Integer> Syntax error, parameterized types are only available if source level is 5.0 The type List is not generic; it cannot be parameterized with arguments <String> Syntax error, parameterized types are only available if source level is 5.0 FacadeException cannot be resolved to a type log cannot be resolved InputStream cannot be resolved to a type FileInputStream cannot be resolved to a type Workbook cannot be resolved to a type Workbook cannot be resolved Sheet cannot be resolved to a type The type List is not generic; it cannot be parameterized with arguments <String> Syntax error, parameterized types are only available if source level is 5.0 ArrayList cannot be resolved to a type Syntax error, parameterized types are only available if source level is 5.0 CarInsModificationInfo cannot be resolved to a type CarInsModificationInfo cannot be resolved to a type StringUtils cannot be resolved Pattern cannot be resolved Pattern cannot be resolved carInsModificationDAO cannot be resolved carInsModificationDAO cannot be resolved StringUtils cannot be resolved StringUtils cannot be resolved StringUtils cannot be resolved StringUtils cannot be resolved carInsModificationDAO cannot be resolved CmodiType cannot be resolved to a type CmodiType cannot be resolved to a type StringUtils cannot be resolved StringUtils cannot be resolved Date cannot be resolved to a type DateFormater cannot be resolved DateFormater cannot be resolved Date cannot be resolved to a type carInsModificationDAO cannot be resolved FacadeException cannot be resolved to a type log cannot be resolved at util.ExcelServlet.<init>(ExcelServlet.java:40) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. 2009-3-29 3:51:38 org.apache.catalina.core.StandardWrapperValve invoke 信息: Servlet ExcelServlet is currently unavailable 代码是: public class ExcelServlet extends HttpServlet { public ExcelServlet() { super(); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { File file = new File("C:/adminexcel.xls"); try { System.out.println(read(file)); } catch (Exception e) { System.out.println(e.getMessage()); } } public static String read(File file) throws Exception { StringBuffer sb = new StringBuffer(); Workbook wb = null; try { wb = Workbook.getWorkbook(file); if (wb != null) { Sheet[] sheets = wb.getSheets(); if (sheets != null && sheets.length != 0) { for (int i=0;i<sheets.length;i++) { int rows = sheets[i].getRows(); for (int j=0;j<rows;j++) { Cell[] cells = sheets[i].getRow(j); if (cells != null && cells.length != 0) { for (int k=0;k<cells.length;k++) { String cell = cells[k].getContents(); System.out.println(cell); sb.append(cell + "\t"); } sb.append("\t\n"); } } sb.append("\t\n"); } } System.out.println("成功" + file + "\n"); } } catch (Exception e) { System.out.println(e.getMessage()); } finally { wb.close(); } return sb.toString(); } }

Java题目,求大神帮忙看看怎么修改,一直有两处错误?

package tf1703; import java.awt.Color; import java.awt.Graphics; //import Tank.Direction; public class Tank { public int x,y,w,h; Enum Direction{L,LU,U,RU,R,RD,D,LD,STOP}; public Direction dir=Direction.U; public Tank(int x,int y,int w,int h,Direction dir) { this.x=x; this.y=y; this.w=w; this.h=h; this.dir=dir; } public void draw(Graphics g) { g.setColor(Color.green); g.fillOval(x,y,w,h); switch(this.dir) { case U: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x+w/2, y-10); break; case LU: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x, y); break; case L: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x-10, y+h/2); break; case LD: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x, y+h); break; case D: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x+w/2, y+h+10); break; case RD: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x+w, y+h); break; case R: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x+w+10, y+h/2); break; case RU: g.setColor(Color.black); g.drawLine(x+w/2, y+h/2, x+w, y); break; } } } package tf1703; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import tf1703.Tank.Direction; public class TFrame extends Frame{ public int frameX=100; public int frameY=100; public int frameH=800; public int frameW=1200; public Tank myTank=null; public TFrame() { this.setBounds(frameX,frameY,frameW,frameH); this.setBackground(Color.pink); this.myTank=new Tank(200,200,100,100,Tank.Direction.RU); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(-1); } }); this.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if(e.getKeyCode()==KeyEvent.VK_A) { System.out.println("你按了A"); myTank.dir=Direction.L; myTank.x=myTank.x-10; }else if(e.getKeyCode()==KeyEvent.VK_S) { System.out.println("你按了S"); myTank.dir=Direction.D; myTank.y=myTank.y+10; } else if(e.getKeyCode()==KeyEvent.VK_D) { System.out.println("你按了D"); myTank.dir=Direction.R; myTank.x=myTank.x+10; } else if(e.getKeyCode()==KeyEvent.VK_W) { System.out.println("你按了W"); myTank.dir=Direction.U; myTank.y=myTank.y-10; } repaint(); } }); this.setVisible(true); } public void paint(Graphics g) { this.myTank.draw(g); } public static void main(String[] args) { new TFrame(); } } Exception in thread "main" java.lang.Error: Unresolved compilation problems: The import tf1703.Tank.Direction cannot be resolved Cannot make a static reference to the non-static field Tank.Direction Direction cannot be resolved to a type Direction cannot be resolved to a variable Direction cannot be resolved to a type Direction cannot be resolved to a variable Direction cannot be resolved to a type Direction cannot be resolved to a variable Direction cannot be resolved to a type Direction cannot be resolved to a variable at tf1703.TFrame.<init>(TFrame.java:9) at tf1703.TFrame.main(TFrame.java:86)

JSP2自定义标签报cannot be resolved to a type问题

学习JSP2自定义标签的内容,没有使用开发工具,编写了标签类HelloWorldTag.java,标签库定义文件mytaglib.tld,以及使用自定义标签的jsp页面HelloWorldTag.jsp。启动tomcat后,访问HelloWorldTag.jsp页面,报HelloWorldTag cannot be resolved to a type错误,但我之前已经使用javac命令手动编译了标签类HelloWorldTag.java,并将生成的class文件放到了WEB-INF/classes路径下了。 代码:①HelloWorldTag.java ``` import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.SimpleTagSupport; public class HelloWorldTag extends SimpleTagSupport { public void doTag() throws JspException,IOException { getJspContext().getOut().write("Hello World"+new java.util.Date()); } } ``` ②mytaglib.tld ``` <?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0"> <description>A tag library exercising SimpleTag handlers.</description> <tlib-version>1.0</tlib-version> <short-name>mytaglib</short-name> <uri>http://www.jjp.org/mytaglib</uri> <tag> <name>helloWorld</name> <tag-class>HelloWorldTag</tag-class> <body-content>empty</body-content> </tag> </taglib> ``` ③HelloWorldTag.jsp ``` <%@ page contentType="text/html;charset=GBK" language="java" errorPage="" %> <%@ taglib uri="http://www.jjp.org/mytaglib" prefix="jjp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>自定义标签示例</title> <head> <body> <h3>以下是自定义标签中的内容</h3> <jjp:helloWorld/> </body> </html> ```

java web开发中,浏览器显示为XXX cannot be resolved to a type

源代码如下,工程里导入了mail.jar和activation.jar ![图片说明](https://img-ask.csdn.net/upload/201603/02/1456922749_442430.png) 编译的时候没问题。 但是浏览器跳出来的结果就这样了: ![图片说明](https://img-ask.csdn.net/upload/201603/02/1456922846_481698.png) 这怎么回事?凡是用到第三方jar包都会出现XXX cannot be resolved to a type的这种结果,为什么eclipse编译的时候能成功,经过Tomcat服务器后就显示这个结果? Sesseion对象是定义在第三方mail.jar包中的。我都import引入该包了,编译器也没报错,但为什么运行后浏览器识别不出?

SmartUpload cannot be resolved to a type这是什么错误

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% SmartUpload smart = new SmartUpload(); smart.initialize(pageContext); smart.upload(); smart.save("upload"); %> </body> </html> SmartUpload smart = new SmartUpload();出现这个错误怎么回事 错误提到SmartUpload cannot be resolved to a type

eclipse导入了jar包但是import时报错:The import com.alibaba cannot be resolved

![图片说明](https://img-ask.csdn.net/upload/202004/25/1587792266_437946.png) 已导入jar包目录如此 ![图片说明](https://img-ask.csdn.net/upload/202004/25/1587792351_382673.png) 导入成功了 但是。。。 一直报错:DruidDataSourceFactory cannot be resolved ![图片说明](https://img-ask.csdn.net/upload/202004/25/1587792464_723500.png) ![图片说明](https://img-ask.csdn.net/upload/202004/25/1587792477_942402.png) 已经进行了删除重引入,project里clean操作,毫无卵用。。。望帮助 代码如下。。。 ``` package Ex13_JDBC; import com.alibaba.druid.pool.DruidDataSourceFactory; import javax.sql.DataSource; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.util.Properties; /** * Druid * 用连接池查询user表中的数据 */ public class JdbcDruidDemo { public static void main(String[] args) { //将这些弄到大括号外面提升作用域,好释放资源 Connection conn = null; Statement stmt = null; ResultSet rs = null; try { //1. 导入druid相应的jar包 //2. 定义配置文件 //2.1 定义一个io流集合 Properties pro = new Properties(); //2.2 将druid.properties文件读取出来并写入Properties集合中 pro.load(JdbcDruidDemo.class.getClassLoader().getResourceAsStream("druid.properties")); //3. 创建数据库连接池对象 通过工厂来获取 DruidDataSourceFactory 然后传递Properties对象 实现标准接口:DataSource DataSource ds = DruidDataSourceFactory.createDataSource(pro); //4. 获取数据库连接对象 conn = ds.getConnection(); //5. 创建sql语句 String sql = "select * from user"; //6. 创建执行sql对象 stmt = conn.createStatement(); //7. 创建一个ResultSet:结果集对象,封装查询结果 rs = stmt.executeQuery(sql); //8. 然后在用ResultSet里的方法 next():游标向下移动一行 判断是否有数据 有就是true,没有就是false while (rs.next()) { //rs.getString():传递的是数据库的字段 String username = rs.getString("username"); int password = rs.getInt("password"); //9. 输入结果 System.out.println(username + " " + password); } } catch (Exception e) { e.printStackTrace(); }finally{ //10. 释放资源 try { if(rs != null){ rs.close(); } }catch(Exception e){ e.printStackTrace(); } try { if(stmt != null){ stmt.close(); } }catch(Exception e){ e.printStackTrace(); } try { if(conn != null){ conn.close(); } }catch(Exception e){ e.printStackTrace(); } } } } ```

JSP 报错 The import org.json cannot be resolved

![图片说明](https://img-ask.csdn.net/upload/201611/14/1479090794_796460.png)

Type CENTER cannot be resolved or is not a field

我刚学java,求助:编译报错:Type CENTER cannot be resolved or is not a field 报错代码为: getContentPane().add(p1, BorderLayout.NORTH); getContentPane().add(p2, BorderLayout.SOUTH); getContentPane().add(new JScrollPane(tbl), BorderLayout.CENTER); 具体全部代码如下: import javax.swing.*; import java.awt.*; class mWin extends JFrame { JTable tbl; Object data[][]; Object title[] = {"学号", "姓名", "性别", "出生年月"}; final int ROW = 5; final int COL = 4; JPanel p1, p2; public mWin(String s) { super(s); data = new Object[ROW][COL]; for (int i = 0; i < ROW; i++) { for (int j = 0; j < COL; j++) { data[i][j] = ""; } } tbl = new JTable(data, title); p1 = new JPanel(); p2 = new JPanel(); p1.add(new JLabel("学生基本信息")); getContentPane().add(p1, BorderLayout.NORTH); getContentPane().add(p2, BorderLayout.SOUTH); getContentPane().add(new JScrollPane(tbl), BorderLayout.CENTER); setSize(240, 200); setVisible(true); validate(); } } public static void main(String[] args) { new mWin("表格的例子"); } }

Android开发 eclipse ...cannot be resolved

Android 新人 [code=java]package com.example.ex03_01; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; import android.widget.EditText; import android.widget.Button; public class MainActivity extends Activity { private TextView txt; private EditText edit; private Button myButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txt= (TextView)findViewById(R.id.textView1); edit= (EditText)findViewById(R.id.editText1); myButton= (Button)findViewById(R.id.button1); myButton.setOnClickListener(new mClick()); } } class mClick implements OnClickListener{ public void onClick(View v){ String inputStr; inputStr=edit.getText().toString(); txt.setTxt(inputStr); } }[/code] 报错: edit cannot be resolved ; txt cannot be resolved; warning: The value of the field MainActivity.edit (txt) is not used. res中并没有相关报错。。网上没找着对应的原因和解决方法 应该不是版本问题 ![图片说明](https://img-ask.csdn.net/upload/201711/03/1509682753_765852.png)

用struts2开发项目时jsp报cannot be resolved to a type错误

![图片说明](https://img-ask.csdn.net/upload/201812/20/1545317905_522127.png) 这是项目的目录,在main.jsp中这句话会报错: SqlSrvDBConn sqlsrvdb=new SqlSrvDBConn(); 错误信息为SqlSrvDBConn cannot be resolved to a type 但是下面实例化LyTable类的时候却不报错,似乎不是import语句的错误 这是import语句:<%@ page import="java.util.*,java.sql.*,org.easybooks.test.model.vo.*,org.easybooks.test.jdbc.*"%> 请问怎么解决?

JSP代码运行报错,can't be resolved

这是我的代码: ``` <%@ page contentType="text/html;charset=GB2312" %> <%@ page import="java.util.*"%> <HTML><BODY> <%! Vector v=new Vector(); ServletContext application; synchronized void sendMessage(String s){ application=getServletContext(); v.add(s); application.setAttribute("Mess",v); } %> <% String name=request.getParameter("peopleName"); String title=request.getParameter("Title"); String messages=request.getParameter("messages"); if(name==null){ name="guest"+(int)(Math.random()*10000); } if(title==null){ title="无标题"; } if(messages==null){ messages="无信息"; String time=new Date().toString(); String s="#"+name+"#"+title+"#"+time+"#"+messages+"#"; sendMessage(s); out.print("您的信息已经提交!"); %> <A href="submit.jsp">返回 <A href="showMessage,jsp">查看留言板 </BODY></HTML> ``` 在浏览器中用localhost:8080打开后报错,虽然有错误提示,但我不太清楚该怎么改,以下是错误信息: ``` An error occurred at line: 4 in the jsp file: /messagePane.jsp Vector cannot be resolved to a type 1: <%@ page contentType="text/html;charset=GB2312" %> 2: <%@ page import="java.ytil.*"%> 3: <HTML><BODY> 4: <%! Vector v=new Vector(); 5: ServletContext application; 6: synchronized void sendMessage(String s){ 7: application=getServletContext(); ``` ``` An error occurred at line: 8 in the jsp file: /messagePane.jsp v cannot be resolved An error occurred at line: 9 in the jsp file: /messagePane.jsp v cannot be resolved to a variable 5: ServletContext application; 6: synchronized void sendMessage(String s){ 7: application=getServletContext(); 8: v.add(s); 9: application.setAttribute("Mess",v); 10: } 11: %> ``` ``` An error occurred at line: 23 in the jsp file: /messagePane.jsp Date cannot be resolved to a type 20: } 21: if(messages==null){ 22: messages="无信息"; 23: String time=new Date().toString(); 24: String s="#"+name+"#"+title+"#"+time+"#"+messages+"#"; 25: sendMessage(s); 26: out.print("您的信息已经提交!"); ``` 感觉从语法上并没有什么错,错误提示也都是can't be resolved,到底是哪里出了问题呢?

intellij idea导入eclipse创建的maven web项目 jar包导入总是报错

** 软件环境**: spring+springMVC+mybatis+ mysql; tomcat服务器; maven项目 eclipse工具运行正常; **问题描述:** maven的jar包依赖没有导入成功,maven配置正常 沿用了阿里云的中心库eclipse可用; 报错截图1: ![图片说明](https://img-ask.csdn.net/upload/201811/12/1542032523_181718.png) ``` nformation:java: Errors occurred while compiling module 'miaolanghzong' Information:Eclipse compiler 4.7.2 was used to compile java sources Information:2018/11/12 21:56 - Compilation completed with 133 errors and 418 warnings in 29 s 620 ms D:\career\workspaceTest2\erzhentang\src\main\java\com\app\totalController\MemberBusinessController.java Error:Error:line (1)java: Syntax error on token "Invalid Character", delete this token Error:Error:line (13)java: The import javax.servlet.http.HttpServletRequest cannot be resolved Error:Error:line (14)java: The import javax.servlet.http.HttpServletResponse cannot be resolved Error:Error:line (47)java: The import com.google.gson cannot be resolved Error:Error:line (659)java: HttpServletRequest cannot be resolved to a type Error:Error:line (659)java: HttpServletResponse cannot be resolved to a type Error:Error:line (623)java: HttpServletRequest cannot be resolved to a type Error:Error:line (623)java: HttpServletResponse cannot be resolved to a type Error:Error:line (894)java: HttpServletRequest cannot be resolved to a type Error:Error:line (894)java: HttpServletResponse cannot be resolved to a type Error:Error:line (806)java: HttpServletRequest cannot be resolved to a type Error:Error:line (806)java: HttpServletResponse cannot be resolved to a type Error:Error:line (198)java: HttpServletRequest cannot be resolved to a type Error:Error:line (198)java: HttpServletResponse cannot be resolved to a type Error:Error:line (277)java: HttpServletRequest cannot be resolved to a type Error:Error:line (277)java: HttpServletResponse cannot be resolved to a type Error:Error:line (134)java: HttpServletRequest cannot be resolved to a type Error:Error:line (134)java: HttpServletResponse cannot be resolved to a type Error:Error:line (460)java: HttpServletRequest cannot be resolved to a type Error:Error:line (460)java: HttpServletResponse cannot be resolved to a type Error:Error:line (540)java: HttpServletRequest cannot be resolved to a type Error:Error:line (540)java: HttpServletResponse cannot be resolved to a type Error:Error:line (109)java: HttpServletRequest cannot be resolved to a type Error:Error:line (109)java: HttpServletResponse cannot be resolved to a type Error:Error:line (411)java: HttpServletRequest cannot be resolved to a type Error:Error:line (411)java: HttpServletResponse cannot be resolved to a type Warning:Warning:line (114)java: The static method sendCode(java.lang.String) from the type com.app.util.Alidayu should be accessed in a static way Warning:Warning:line (154)java: The static method md5Encode(java.lang.String) from the type com.app.util.MD5Util should be accessed in a static way Warning:Warning:line (207)java: The static method md5Encode(java.lang.String) from the type com.app.util.MD5Util should be accessed in a static way Warning:Warning:line (286)java: The static method md5Encode(java.lang.String) from the type com.app.util.MD5Util should be accessed in a static way Warning:Warning:line (421)java: The static method md5Encode(java.lang.String) from the type com.app.util.MD5Util should be accessed in a static way Warning:Warning:line (469)java: The static method md5Encode(java.lang.String) from the type com.app.util.MD5Util should be accessed in a static way Warning:Warning:line (549)java: The static method md5Encode(java.lang.String) from the type com.app.util.MD5Util should be accessed in a static way D:\career\workspaceTest2\erzhentang\src\main\java\com\app\common\LoginFilter.java Error:Error:line (23)java: Filter cannot be resolved to a type Error:Error:line (37)java: ServletException cannot be resolved to a type Error:Error:line (36)java: ServletRequest cannot be resolved to a type Error:Error:line (36)java: ServletResponse cannot be resolved to a type Error:Error:line (37)java: FilterChain cannot be resolved to a type Error:Error:line (106)java: ServletException cannot be resolved to a type Error:Error:line (106)java: FilterConfig cannot be resolved to a type Error:Error:line (7)java: The import javax.servlet.Filter cannot be resolved Error:Error:line (8)java: The import javax.servlet.FilterChain cannot be resolved Error:Error:line (9)java: The import javax.servlet.FilterConfig cannot be resolved Error:Error:line (10)java: The import javax.servlet.ServletException cannot be resolved Error:Error:line (11)java: The import javax.servlet.ServletRequest cannot be resolved Error:Error:line (12)java: The import javax.servlet.ServletResponse cannot be resolved Error:Error:line (13)java: The import javax.servlet.http.HttpServletRequest cannot be resolved Error:Error:line (14)java: The import javax.servlet.http.HttpServletResponse cannot be resolved Error:Error:line (15)java: The import javax.servlet.http.HttpSession cannot be resolved Error:Error:line (24)java: FilterConfig cannot be resolved to a type Warning:Warning:line (26)java: java.util.List is a raw type. References to generic type java.util.List<E> should be parameterized Warning:Warning:line (28)java: java.util.List is a raw type. References to generic type java.util.List<E> should be parameterized Error:Error:line (33)java: FilterConfig cannot be resolved to a type Error:Error:line (39)java: HttpServletRequest cannot be resolved to a type Error:Error:line (39)java: HttpServletRequest cannot be resolved to a type Error:Error:line (40)java: HttpServletResponse cannot be resolved to a type Error:Error:line (40)java: HttpServletResponse cannot be resolved to a type Error:Error:line (41)java: HttpSession cannot be resolved to a type Error:Error:line (107)java: FilterConfig cannot be resolved to a type Error:Error:line (108)java: FilterConfig cannot be resolved to a type Error:Error:line (113)java: FilterConfig cannot be resolved to a type D:\career\workspaceTest2\erzhentang\src\main\java\com\app\dao\impl\MemberDaoImpl.java Warning:Warning:line (42)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized Warning:Warning:line (63)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized Warning:Warning:line (110)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized Warning:Warning:line (9)java: The import com.app.bean.Menu is never used D:\career\workspaceTest2\erzhentang\src\main\java\com\app\dao\impl\EarProblemDaoImpl.java Warning:Warning:line (18)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized Warning:Warning:line (48)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized D:\career\workspaceTest2\erzhentang\src\main\java\com\app\dao\impl\BodyConclusionDaoImpl.java Warning:Warning:line (25)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized Warning:Warning:line (11)java: The import com.app.bean.BodyConclusionWuxing is never used D:\career\workspaceTest2\erzhentang\src\main\java\com\app\dao\mapper\EarDisease100Mapper.java Warning:Warning:line (14)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized D:\career\workspaceTest2\erzhentang\src\main\java\com\app\dao\BlueToochMacDao.java Warning:Warning:line (12)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized Warning:Warning:line (14)java: java.util.Map is a raw type. References to generic type java.util.Map<K,V> should be parameterized D:\career\workspaceTest2\erzhentang\src\main\java\com\app\dao\EarScanC ``` ![图片说明](https://img-ask.csdn.net/upload/201811/12/1542031436_513761.png) ![图片说明](https://img-ask.csdn.net/upload/201811/12/1542031687_784746.png) ![图片说明](https://img-ask.csdn.net/upload/201811/12/1542031723_457809.png) ![图片说明](https://img-ask.csdn.net/upload/201811/12/1542031745_434340.png) ![图片说明](https://img-ask.csdn.net/upload/201811/12/1542031762_172605.png) ![图片说明](https://img-ask.csdn.net/upload/201811/12/1542031776_649119.png)

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐