求解----Error:(237, 17) java: 找不到符号 1C

public String findByCombination(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
/*
* 1. 得到pc:如果页面传递,使用页面的,如果没传,pc=1
/
int pc = getPc(req);
/

* 2. 得到url:...
/
String url = getUrl(req);
/

* 3. 获取查询条件,本方法就是cid,即分类的id
/
Book criteria = CommonUtils.toBean(req.getParameterMap(), Book.class);
/

* 4. 使用pc和cid调用service#findByCategory得到PageBean
*/

    /*
     * 5. 给PageBean设置url,保存PageBean,转发到/jsps/book/list.jsp
     */
    pb.setUrl(url);
    req.setAttribute("pb", pb);
    return "f:/jsps/book/list.jsp";
}

}

运行出了两个错误
Error:(237, 17) java: 找不到符号
符号: 变量 pb
位置: 类 cn.njcit.goods.book.web.servlet.BookServlet
Error:(238, 40) java: 找不到符号
符号: 变量 pb
位置: 类 cn.njcit.goods.book.web.servlet.BookServlet

0

3个回答

/*
* 5. 给PageBean设置url,保存PageBean,转发到/jsps/book/list.jsp
*/
pb.setUrl(url);
req.setAttribute("pb", pb);
return "f:/jsps/book/list.jsp";

    错误提示已经很明显了,找不到符号 变量pb。  你的第5步中pb变量没有定义
0

但是我上面的方法也是这么定义的 就没错啊

package cn.njcit.goods.book.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.itcast.commons.CommonUtils;
import cn.itcast.goods.book.domain.Book;
import cn.itcast.goods.book.service.BookService;
import cn.itcast.goods.pager.PageBean;
import cn.itcast.servlet.BaseServlet;

public class BookServlet extends BaseServlet {
private BookService bookService = new BookService();

/**
 * 获取当前页码
 *
 * @param req
 * @return
 */
private int getPc(HttpServletRequest req) {
    int pc = 1;
    String param = req.getParameter("pc");
    if (param != null && !param.trim().isEmpty()) {
        try {
            pc = Integer.parseInt(param);
        } catch (RuntimeException e) {
        }
    }
    return pc;
}

/**
 * 截取url,页面中的分页导航中需要使用它做为超链接的目标!
 *
 * @param req
 * @return
 */
/*
 * http://localhost:8080/goods/BookServlet?methed=findByCategory&cid=xxx&pc=3
 * /goods/BookServlet + methed=findByCategory&cid=xxx&pc=3
 */
private String getUrl(HttpServletRequest req) {
    String url = req.getRequestURI() + "?" + req.getQueryString();
    /*
     * 如果url中存在pc参数,截取掉,如果不存在那就不用截取。
     */
    int index = url.lastIndexOf("&pc=");
    if (index != -1) {
        url = url.substring(0, index);
    }
    return url;
}

/**
 * 按bid查询
 *
 * @param req
 * @param resp
 * @return
 * @throws ServletException
 * @throws IOException
 */
public String load(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    String bid = req.getParameter("bid");//获取链接的参数bid
    Book book = bookService.load(bid);//通过bid得到book对象
    req.setAttribute("book", book);//保存到req中
    return "f:/jsps/book/desc.jsp";//转发到desc.jsp
}

/**
 * 按分类查
 *
 * @param req
 * @param resp
 * @return
 * @throws ServletException
 * @throws IOException
 */
public String findByCategory(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    /*
     * 1. 得到pc:如果页面传递,使用页面的,如果没传,pc=1
     */
    int pc = getPc(req);
    /*
     * 2. 得到url:...
     */
    String url = getUrl(req);
    /*
     * 3. 获取查询条件,本方法就是cid,即分类的id
     */
    String cid = req.getParameter("cid");
    /*
     * 4. 使用pc和cid调用service#findByCategory得到PageBean
     */
    PageBean<Book> pb = bookService.findByCategory(cid, pc);
    /*
     * 5. 给PageBean设置url,保存PageBean,转发到/jsps/book/list.jsp
     */
    pb.setUrl(url);
    req.setAttribute("pb", pb);
    return "f:/jsps/book/list.jsp";
}

/**
 * 按作者查
 *
 * @param req
 * @param resp
 * @return
 * @throws ServletException
 * @throws IOException
 */
public String findByAuthor(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    /*
     * 1. 得到pc:如果页面传递,使用页面的,如果没传,pc=1
     */
    int pc = getPc(req);
    /*
     * 2. 得到url:...
     */
    String url = getUrl(req);
    /*
     * 3. 获取查询条件,本方法就是cid,即分类的id
     */
    String author = req.getParameter("author");
    /*
     * 4. 使用pc和cid调用service#findByCategory得到PageBean
     */
    PageBean<Book> pb = bookService.findByAuthor(author, pc);
    /*
     * 5. 给PageBean设置url,保存PageBean,转发到/jsps/book/list.jsp
     */
    pb.setUrl(url);
    req.setAttribute("pb", pb);
    return "f:/jsps/book/list.jsp";
}

/**
 * 按出版社查询
 *
 * @param req
 * @param resp
 * @return
 * @throws ServletException
 * @throws IOException
 */
public String findByPress(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    /*
     * 1. 得到pc:如果页面传递,使用页面的,如果没传,pc=1
     */
    int pc = getPc(req);
    /*
     * 2. 得到url:...
     */
    String url = getUrl(req);
    /*
     * 3. 获取查询条件,本方法就是cid,即分类的id
     */
    String press = req.getParameter("press");
    /*
     * 4. 使用pc和cid调用service#findByCategory得到PageBean
     */
    PageBean<Book> pb = bookService.findByPress(press, pc);
    /*
     * 5. 给PageBean设置url,保存PageBean,转发到/jsps/book/list.jsp
     */
    pb.setUrl(url);
    req.setAttribute("pb", pb);
    return "f:/jsps/book/list.jsp";
}

/**
 * 按图名查
 *
 * @param req
 * @param resp
 * @return
 * @throws ServletException
 * @throws IOException
 */
public String findByBname(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    /*
     * 1. 得到pc:如果页面传递,使用页面的,如果没传,pc=1
     */
    int pc = getPc(req);
    /*
     * 2. 得到url:...
     */
    String url = getUrl(req);
    /*
     * 3. 获取查询条件,本方法就是cid,即分类的id
     */
    String bname = req.getParameter("bname");
    /*
     * 4. 使用pc和cid调用service#findByCategory得到PageBean
     */
    PageBean<Book> pb = bookService.findByBname(bname, pc);
    /*
     * 5. 给PageBean设置url,保存PageBean,转发到/jsps/book/list.jsp
     */
    pb.setUrl(url);
    req.setAttribute("pb", pb);
    return "f:/jsps/book/list.jsp";
}

}

// /**
// * 多条件组合查询
// * @param req
// * @param resp
// * @return
// * @throws ServletException
// * @throws IOException
// /
// public String findByCombination(HttpServletRequest req, HttpServletResponse resp)
// throws ServletException, IOException {
// /

// * 1. 得到pc:如果页面传递,使用页面的,如果没传,pc=1
// /
// int pc = getPc(req);
// /

// * 2. 得到url:...
// /
// String url = getUrl(req);
// /

// * 3. 获取查询条件,本方法就是cid,即分类的id
// /
// Book criteria = CommonUtils.toBean(req.getParameterMap(), Book.class);
// /

// * 4. 使用pc和cid调用service#findByCategory得到PageBean
// /
//
// /

// * 5. 给PageBean设置url,保存PageBean,转发到/jsps/book/list.jsp
// */
// pb.setUrl(url);
// req.setAttribute("pb", pb);
// return "f:/jsps/book/list.jsp";
// }
//}


0

/*
* 4. 使用pc和cid调用service#findByCategory得到PageBean
*/
PageBean pb = bookService.findByBname(bname, pc);

你上面方法都定义了pb变量啊, 你的findByCombination方法里可没有定义啊

0
z562743237
zsc我行我素 你的findByCombination方法里第4步少了一步操作啊
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
初学java,找不到符号,求解?
![这是我写的java代码](https://img-ask.csdn.net/upload/201612/05/1480929835_958470.png)n![这个是错误信息](https://img-ask.csdn.net/upload/201612/05/1480930042_357208.png)nnhtml文件我也写过了![html文件](https://img-ask.csdn.net/upload/201612/05/1480929947_706334.png)n![运行以后是这样的,,](https://img-ask.csdn.net/upload/201612/05/1480930071_373793.png)nn来请教一下大家! 谢谢了
找不到符号~~ 求解!!!
代码如下:rninterface Choose //接口rnrn String Choose(); //选课rnrnclass Student //定义一个名为Student的父类rnrn String name;//姓名rn char sex;//性别rn String grade;//年级rn public Student()rn rn public Student(String n,char s,String g)//定义构造方法,用来进行初始化rn rn name=n;//将传递进来的n赋给namern sex=s;//将传递进来的s赋给sexrn grade=g;//将传递进来的g赋给gradern rn public void setname(String newname)//设置姓名rn rn name=newname;rn rn public String getname() //获取姓名rn rn return name;rn rn public void setsex(char newsex) //设置性别rn rn sex=newsex;rn rn public char getsex()//获取性别rn rn return sex;rn rn public void setgrade(String newgrade)//设置年级rn rn grade=newgrade;rn rn public String getgrade()//获取年级rn rn return grade;rn rnrnclass Academician extends Student //继承于Student的子类:大学生rnrn int Aage;//年龄rn public Academician()rn rn public Academician(String n,char s,String g,int A) //定义构造方法,用来进行初始化rn rn super(n,s,g);//调用父类的构造方法rn Aage=A;rn rn public void setAage(int newAage)//设置年龄rn rn Aage=newAage;rn rn public int getAage()//获取年龄rn rn return Aage;rn rn public String Choose()//实现选课接口rn rn return "正在进入选课系统";rn rnrnclass Pupil extends Student//继承于Student的子类:小学生rnrn int Page;//年龄rn public Pupil()rn rn public Pupil(String n,char s,String g,int P) //定义构造方法,用来进行初始化rn rn super(n,s,g);//调用父类的构造方法rn Page=P;rn rn public void setPage(int newPage)//设置年龄rn rn Page=newPage;rn rn public int getPage()//获取年龄rn rn return Page;rn rnrnpublic class xqq_Applicationjichu1 //编写测试类rnrn public static void main(String args[])rn rn Academician A1=new Academician("张三","男","大学一年级",18); //给大学生A1赋值rn System.out.println("姓名:"+A1.getname());rn System.out.println("性别:"+A1.getsex());rn System.out.println("年级:"+A1.getgrade());rn System.out.println("年龄:"+A1.getAage());rn System.out.println("选课情况:"+A1.Choose());rn System.out.println("\n\n");rn Pupil P1=new Pupil("李四","女","二年级",8); //给小学生P1赋值rn System.out.println("姓名:"+P1.getname());rn System.out.println("性别:"+P1.getsex());rn System.out.println("年级:"+P1.getgrade());rn System.out.println("年龄:"+P1.getPage());rn rnrn编译错误提示:rnC:\Users\xuqianqian\Desktop\xqq_Applicationjichu1.java:89: 找不到符号rn符号: 构造函数 Academician(java.lang.String,java.lang.String,java.lang.String,int)rn位置: 类 Academicianrn Academician A1=new Academician("张三","男","大学一年级",18); //给大学生A1赋值rn ^rnC:\Users\xuqianqian\Desktop\xqq_Applicationjichu1.java:96: 找不到符号rn符号: 构造函数 Pupil(java.lang.String,java.lang.String,java.lang.String,int)rn位置: 类 Pupilrn Pupil P1=new Pupil("李四","女","二年级",8); //给小学生P1赋值rn求解~!!!
找不到符号的,求解
import javax.swing.JOptionPane;rnpublic class Printrn public static void main(String arge[])rn rn String input = JOptionPane.showInputDialog(null,"请输入行数:");rn int row = Integer.parseInt(input);rn if(row < 1|| row >15)rn rn System.out.println("输入错误!");rn System.exit(0);rn rn for(int i=1;i<= row;i++)rn rn for(int a=1;a<=row-1;a++)rn System.out.print(" ");rn for(int b=i;b>0;b--)rn System.out.print(b);rn for(int d=1;d<=i;d++);rn System.out.print(d+1);rn System.out.println();rn rn rn
error 找不到符号 符号:类 jsonobject
/C:/Users/ligang/Desktop/demo/src/main/java/com/jksoft/demo/util/WeixinUtil.java:[27,17] 找不到符号rn[ERROR] 符号: 类 JSONObjectrn[ERROR] 位置: 类 com.jksoft.demo.util.WeixinUtilrn[ERROR] /C:/Users/ligang/Desktop/demo/src/main/java/com/jksoft/demo/util/WeixinUtil.java:[56,38] 找不到符号rn[ERROR] 符号: 变量 JSONObjectrn[ERROR] 位置: 类 com.jksoft.demo.util.WeixinUtilrn[ERROR] /C:/Users/ligang/Desktop/demo/src/main/java/com/jksoft/demo/util/WeixinUtil.java:[75,13] 找不到符号rn[ERROR] 符号: 类 JSONObjectrn[ERROR] 位置: 类 com.jksoft.demo.util.WeixinUtilrnrnrnrnpublic class WeixinUtil rn /** rn * 发起https请求并获取结果 rn * rn * @param requestUrl 请求地址 rn * @param requestMethod 请求方式(GET、POST) rn * @param outputStr 提交的数据 rn * @return JSONObject(通过JSONObject.get(key)的方式获取json对象的属性值) rn */ rn public static JSONObject HttpRequest(String request , String RequestMethod , String output )rn @SuppressWarnings("unused")rn JSONObject jsonObject = null;rn StringBuffer buffer = new StringBuffer();rn try rn //建立连接rn URL url = new URL(request);rn HttpURLConnection connection = (HttpURLConnection) url.openConnection();rn connection.setDoOutput(true);rn connection.setDoInput(true);rn connection.setUseCaches(false);rn connection.setRequestMethod(RequestMethod);rn if(output!=null)rn OutputStream out = connection.getOutputStream();rn out.write(output.getBytes("UTF-8"));rn out.close();rn rn //流处理rn InputStream input = connection.getInputStream();rn InputStreamReader inputReader = new InputStreamReader(input,"UTF-8");rn BufferedReader reader = new BufferedReader(inputReader);rn String line;rn while((line=reader.readLine())!=null)rn buffer.append(line);rn rn //关闭连接、释放资源rn reader.close();rn inputReader.close();rn input.close();rn input = null;rn connection.disconnect();rn jsonObject = JSONObject.fromObject(buffer.toString());rn catch (Exception e) rn rn return jsonObject;rn rn// 获取access_token的接口地址(GET) rn public final static String access_token_url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=CorpID&corpsecret=SECRET"; rn rn /** rn * 获取access_token rn * rn * @param CorpID 企业Id rn * @param SECRET 管理组的凭证密钥,每个secret代表了对应用、通讯录、接口的不同权限;不同的管理组拥有不同的secret rn * @return rn */ rn public static AccessToken getAccessToken(String corpID, String secret) rn AccessToken accessToken = null; rn rn String requestUrl = access_token_url.replace("CorpID", corpID).replace("SECRET", secret); rn JSONObject jsonObject = HttpRequest(requestUrl, "GET", null); rn // 如果请求成功 rn if (null != jsonObject) rn try rn accessToken = new AccessToken(); rn accessToken.setToken(jsonObject.getString("access_token")); rn accessToken.setExpiresIn(jsonObject.getInt("expires_in"));rn System.out.println("获取token成功:"+jsonObject.getString("access_token")+"————"+jsonObject.getInt("expires_in"));rn catch (Exception e) rn accessToken = null; rn // 获取token失败 rn String error = String.format("获取token失败 errcode: errmsg:", jsonObject.getInt("errcode"), jsonObject.getString("errmsg")); rn System.out.println(error);rn rn rn return accessToken; rn rnrnrn刚刚入职,让做微信企业号开发遇到的问题,求大神帮忙解答一下。
java 中 找不到符号。新手求解!
package examples.has.geom;rnpublic class Geometry rn rn private Rectangle rect; rn private Circle circle; rn rn Geometry(Rectangle rect, Circle circle) rn this.rect = rect; rn this.circle = circle; rn rn rn public void setCirclePosition(double x, double y) rn circle.setX(x); rn circle.setY(y); rn rn rn public void setCircleRadius(double radius) rn circle.setRadius(radius); rn rn rn public void setRectanglePosition(double x, double y) rn rect.setX(x); rn rect.setY(y); rn rn rn public void setRectangleWidthAndHeight(double w, double h) rn rect.setWidth(w); rn rect.setHeight(h); rn rn rn public void showState() rn double circleX = circle.getX(); rn double rectX = rect.getX(); rn rn if((rectX - circleX) == (circle.getRadius() * 2)) rn System.out.println("图形中的矩形在圆的右侧"); rn rn rn if((circleX - rectX) == rect.getWidth()) rn System.out.println("图形中的矩形在圆的右侧"); rn rn rnrn编译之后,出现:rnGeometry.java:4: 错误: 找不到符号rn private Rectangle rect;rn ^rn 符号: 类 Rectanglern 位置: 类 GeometryrnGeometry.java:5: 错误: 找不到符号rn private Circle circle;rn ^rn 符号: 类 Circlern 位置: 类 GeometryrnGeometry.java:7: 错误: 找不到符号rn Geometry(Rectangle rect, Circle circle)rn ^rn 符号: 类 Rectanglern 位置: 类 GeometryrnGeometry.java:7: 错误: 找不到符号rn Geometry(Rectangle rect, Circle circle)rn ^rn 符号: 类 Circlern 位置: 类 Geometryrn4 个错误rn难受,也不知道怎么改。。。
java: 找不到符号
这里写自定义目录标题问题新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 问题 【报错内容】 Error:(4,...
java提示找不到符号
import java.io.*;rnrnrnpublic class TestPipeIoStreamrnrn public static void main( String[] args ) throws Exceptionrn rn PipedOutputStream pos = new PipedOutputStream();rn PipedInputStream pis = new PipedInputStream();rn pos.connect(pis);rn new ThreadSend(pos).run();rn new ThreadRecv(pis).run();rn rnrnrnclass ThreadSend extends Threadrnrn PipedOutputStream pos;rn rn ThreadSend( PipedOutputStream p )rn rn pos = p;rn rn public void run()rn rn tryrn rn pos.write("every one is ".getBytes());rn pos.close();rn catch(Exception e)rn rn e.printStackTrace();rn rn rnrnrnclass ThreadRecv extends Threadrnrn PipedInputStream pis;rn rn ThreadRecv( PipedInputStream p )rn rn pis = p;rn rn public void run()rn rn tryrn rn Byte[] buf = new Byte[100];rn int len = pis.read(buf);rn System.out.println(new String(buf,0,len));rn catch(Exception e)rn rn e.printStackTrace();rn rn rnrn编译错误:rnTestPipeIoStream.java:50: 找不到符号rn符号: 方法 read(java.lang.Byte[])rn位置: 类 java.io.PipedInputStreamrn int len = pis.read(buf);rn ^rnTestPipeIoStream.java:51: 找不到符号rn符号: 构造函数 String(java.lang.Byte[],int,int)rn位置: 类 java.lang.Stringrn System.out.println(new String(buf,0,len));rn ^rn2 错误
JAVA编译时找不到符号
用jxl编写了一个很简短的程序,是从Excel文件读取数据表,用javac编译时说:rn符号: 变量rwbrn位置:Sheet rs = rwb.getSheet(0);rn ^rnrnimport java.io.*;rnimport jxl.*;rnimport jxl.write.*;rnrnpublic class Readingxlsrnrn public static void main(String[] args)rn tryrn rn InputStream is=new FileInputStream("d:/Book1.xls");rn jxl.Workbook rwb = Workbook.getWorkbook(is);rn rn catch(Exception e)e.printStackTrace();rn Sheet rs = rwb.getSheet(0);//获取第一张Sheet表rn Cell c00=rs.getCell(0,0);//获取第一行,第一列的值rn String strc00=c00.getContents();rn System.out.println("Cell(0,0)"+"value:"+strc00);rnrnrn请问这是什么问题?
java编译错误 找不到符号
java编译错误 找不到符号   可以把classpath设置为当前目录,也可以用命令 javac   -d   .   *.java 进行编译!
java 找不到符号
public class Shenqz rn int order[];rn String s_name[]= new String[3];rn String s_add[]= new String[3];rn String s_pos[]= new String[3];rn Shenqz()rn String s_name[] = "zhangsan","lisi","mazi";rn String s_add[] = "hangzhou","beijing","shanghai";rn String s_pos[] = "DBA","DEP","SALES";rn rn rn rn void print()rn for(int i=0;i<=order.length;i++)rn System.out.print(order[i]+";");rn System.out.println();rn rn public static void main(String[] args)rn rn rn Shenqz s1 = new Shenqz(s_name);rn rn s1.print();rn rn Shenqz s2 = new Shenqz(s_add);rn s2.print();rn rn Shenqz s3 = new Shenqz(s_pos);rn s3.print();rn rn rn报错内容是:rnE:\java>javac Shenqz.javarnShenqz.java:21: 无法从静态上下文中引用非静态 变量 s_namern Shenqz s1 = new Shenqz(s_name);rn ^rnShenqz.java:21: 找不到符号rn符号: 构造函数 Shenqz(java.lang.String[])rn位置: 类 Shenqzrn Shenqz s1 = new Shenqz(s_name);rn ^rnShenqz.java:25: 无法从静态上下文中引用非静态 变量 s_addrn Shenqz s2 = new Shenqz(s_add);rn ^rnShenqz.java:25: 找不到符号rn符号: 构造函数 Shenqz(java.lang.String[])rn位置: 类 Shenqzrn Shenqz s2 = new Shenqz(s_add);rn ^rnShenqz.java:28: 无法从静态上下文中引用非静态 变量 s_posrn Shenqz s3 = new Shenqz(s_pos);rn ^rnShenqz.java:28: 找不到符号rn符号: 构造函数 Shenqz(java.lang.String[])rn位置: 类 Shenqzrn Shenqz s3 = new Shenqz(s_pos);rn ^rn6 错误rnrnE:\java>
Java 编译找不到符号
我创建了Dog类,并在主函数中引用了对象,都在同一个文件夹里。但是编译报错找不到符号rn下面是Dog.javarnclass Dogrn int age;rn String name;rn String color;rn void jump()rn System.out.println("jump");rn rnrn下面是DogTest.javarn public class DogTestrn public static void main(String args[])rn Dog d = new Dog();rn d.name = "旺财";rn d.age = 2;rn d.jump();rn System.out.println("狗的名字是"+d.name);rn rn
java编译报错:找不到符号
本段代码完成的功能是,生成一个窗口,窗口上放置有两个按钮,这两个按钮显示的文本分别是"yellow"和"red"。rn但是,在编译时报出如下的错误:rn[b]找不到符号。rn符号名:DEFAULT_WIDTHrn符号名:DEFAULT_HEIGHT[/b]rnrn代码如下,请大家指教,看看问题是什么。rnrnimport java.awt.*;rnimport java.awt.event.*;rnimport javax.swing.*;rnrnpublic class BtnTestrnrn public static void main(String [] args)rn rn EventQueue.invokeLater(new Runnable()rn public void run()rn ButtonFrame frame=new ButtonFrame();rn frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn frame.setVisible(true);rn rn );rn rnrnrnclass ButtonFrame extends JFramernrn public ButtonFrame()rn rn setTitle("afkaka;fka;");rn setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);rnrn JButton yellowBtn=new JButton("yellow");rn JButton redBtn=new JButton("red");rn rn buttonPanel = new JPanel();rn rn buttonPanel.add(yellowBtn);rn buttonPanel.add(redBtn);rnrn add(buttonPanel);rn rn private JPanel buttonPanel;rn
IDEA java:找不到符号
File-Settings-Build,Execution,Deployment-Compiler-Excludes, 点击“+”号,添加本工程
java 编译找不到符号
java 编译时找不到符号问题 ,文章只是做个记录,以后不可再犯类似问题。 代码编写ok后编译: javac ServerSocket.java 出现报错,如下: 完整代码如下: import java.net.*; public class ServerSocket{ public static void main(String[] args){ ServerSocket ss = ne...
java:31: 找不到符号
rnpublic class testarray rn public static void main (String[] args)rn int[] a = new int[args.length];rn for(int i = 0;ia[j])rn k=j;rn rn rn if(k!=i)rn int temp;rn temp = a[i];rn a[i] = a[K];rn a[K] = temp;rn rn rn rn rnrnrnrn--------------------配置: <--------------------rnD:\java\testarray.java:24: 找不到符号rn符号: 变量 Krn位置: 类 testarrayrn if(a[K]>a[j])rn ^rnD:\java\testarray.java:31: 找不到符号rn符号: 变量 Krn位置: 类 testarrayrn a[i] = a[K];rn ^rnD:\java\testarray.java:32: 找不到符号rn符号: 变量 Krn位置: 类 testarrayrn a[K] = temp;rn ^rn3 错误rnrn处理已完成。
java错误,找不到符号
import java.util.Vector;rnimport java.util.Collections;rnimport java.util.ArrayList;rn//import java.util.*;rnpublic class StringUtil rnrn public static String[] stringSort(String [] s) rn rn Vector v = new Vector();rn for (int i = 0; i < s.length; i++) rn rn v.add(s[i]);rn rn Collections.sort(v);rn return v.toArray(s);rn rnrnclass TestStringSortrnrn public static void main(String[] args) rn rn String[] s = new String[]"book", "hello", "world", "enjoy";rn s=stringSort(s);rn for (int i = 0; i < s.length; i++) rn rn System.out.println(s[i]);rn rn rn[img=https://img-bbs.csdn.net/upload/201310/28/1382968214_650999.jpg][/img]求大神指导怎么改
编译.java找不到符号
rnrnBaseConn.javarn----------------------------------------------------------------------------------------------------------------------------rnrnpackage net.chat;rnimport java.sql.*;rnimport java.lang.ClassNotFoundException;rnpublic class BaseConnrn Connection conn=null;rn Statement stmt=null;rn PreparedStatement ps=null;rn ResultSet rs=null;rn/**************************************************************************************rn *BaseConn的构造函数,在这里完成数据库的初始化操作,即连接数据库操作rn **************************************************************************************/rn public BaseConn()throws SQLException,ClassNotFoundExceptionrn tryrn rn String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ChatRoom;SelectMethod=Cursor";rn Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");rn conn=DriverManager.getConnection(url,"sa","");rn stmt=conn.createStatement();rn rn catch(SQLException e)rn rn System.out.println("Error occured when Connect DataBase:"+e);rn throw e;rn rn catch(ClassNotFoundException e)rn rn System.out.println("Error occured when Connect DataBase:"+e);rn throw e;rn rn rn/*************************************************************************************rn *初始化预编译的SQL语句的对象rn************************************************************************************/rn public PreparedStatement prepaeStatement(String sql)throws SQLExceptionrn rn tryrn rn ps=conn.prepareStatement(sql);rn return ps;rn catch(SQLException e)rn rn System.out.println("Error occured when create preparedStatement:"+e);rn throw e;rn rn rn/*************************************************************************************rn *执行静态SQL查询语句并返回它所生成结果的对象rn************************************************************************************/rn public ResultSet ececuteQuery(String sql)throws SQLExceptionrn rn rs=null;rn tryrn rs=stmt.executeQuery(sql);rn rn catch(SQLException ex)rn System.out.println("Error occured when query database:"+ex);rn throw ex;rn rn return rs;rn rn/*************************************************************************************rn *执行静态SQL查询语句并返回影响数据的条数rn************************************************************************************/rn public int executeUpadate(String sql)throws SQLExceptionrn rn tryrn conn.setAutoCommit(false);rn int re=stmt.executeUpdate(sql);rn conn.commit();rn return re;rn rn catch(SQLException e)rn conn.rollback();rn System.out.println("Error occured when update database:"+e);rn throw e; rn rn rn/*************************************************************************************rn *执行预先SQL查询语句rn************************************************************************************/rn public ResultSet executeQuery() throws SQLExceptionrn rn tryrn return ps.executeQuery();rn rn catch(SQLException e)rn System.out.println("Error occured when query database:"+e);rn throw e;rn rn rn/*************************************************************************************rn *执行预编译的SQL更新语句rn************************************************************************************/rn public int executeUpdate() throws SQLExceptionrn rn tryrn conn.setAutoCommit(false);rn int r=ps.executeUpdate();rn conn.commit();rn return r;rn rn catch(SQLException e)rn conn.rollback();rn System.out.println("Error occured when updata database:"+e);rn throw e;rn rn rn/*************************************************************************************rn *数据库关闭操作rn************************************************************************************/ public boolean closeDB() throws SQLExceptionrn rn tryrn if(this.rs!=null)rn rs.close();rn if(this.stmt!=null)rn this.stmt.close();rn if(this.ps!=null)rn this.ps.close();rn if(this.conn!=null)rn conn.close();rn return true;rn rn catch (SQLException e)rn System.out.println("Error occured when close database:"+e);rn throw e;rn rn rn rn rnrn---------------------------------------------------------------------------------------------------------------------------rnBaseConn.java编译通过 rnrnrnrnCheckLogin.java rnrn----------------------------------------------------------------------------------------------------------------------------rn rnpackage net.chat;rnimport java.sql.*;rnimport java.util.*;rnimport java.text.SimpleDateFormat;rnimport java.lang.ClassNotFoundException;rnpublic class CheckLoginrn/*rn 检测用户登陆信息rn 用户登陆的用户名rn 用户登陆的密码rn */rn public String checklogin(String userName,String userPassword) throws SQLException,ClassNotFoundExceptionrn rn BaseConn conn=null;rn tryrn rn conn=new BaseConn();rn //创建一个预先处理的SQL语句rn String sql="select *from userInfo where nickName=?";rn //创建一个预先处理的SQL对象rn PreparedStatement ps=conn.preparedStatement(sql);rn ps.setString(1,userName);rn //从用户数据库中查询该用户名是否在数据库中rn ResultSet rs=conn.executeQuery();rn if(rs.next())rn rn if(rs.getString("userPassword").equals(userPassword))rn rn SimpleDateFormat cal=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");rn String time=cal.format(new java.util.Date());rn //修改用户的最后登陆时间rn sql="update userinfo set lastLoginTime?where nickName=?";rn ps=conn.prepareStatement(sql);rn ps.setString(1,time);rn ps.setString(2,userName);rn conn.executeUpdate();rn return "SUCCESS_LOGIN";rn rn elsern return "WRONG_PASSWORD";rn rn elsern return "NONE_USER";rn catch(SQLException ex)rn rn ex.printStackTrace();rn throw ex;rn catch(ClassNotFoundException ex)rn rn ex.printStackTrace();rn throw ex;rn rn finallyrn rn conn.close();//关闭数据库连接,释放JDBC资源rn rn rn /*rn 如果是新用户,则将用户登陆用户名和密码保存到数据库中rn */rn public boolean saveToDataBase(String userName,String userPassword) throws SQLException,ClassNotFoundExceptionrn rn BaseConn conn=null;rn tryrn rn conn=new BaseConn();rn SimpleDateFormat cal=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");rn String time=cal.format(new java.util.Date());rn String sql="insert into userInfo(nickName,userPassword,lastLoginTime)values (?,?,?)";rn PreparedStatement ps =conn.prepareStatement(sql);rn ps.setString(1,userName);rn ps.setString(2,userPassword);rn ps.setString(3,time);rn conn.executeUpdate();rn return true;rn catch(SQLException ex)rn rn ex.printStackTrace();rn throw ex;rn finallyrn rn conn.close();//关闭数据库连接,释放JDBC资源rn rn rnrnrn------------------------------------------------------------------------------------------------------------------------------rnrnCheckLogin.java 编译的时候 出现错误 rnrnD:\ChatRoom\WEB-INF>javac CheckLogin.javarnCheckLogin.java:14: 找不到符号rn符号: 类 BaseConnrn位置: 类 net.chat.CheckLoginrn BaseConn conn=null;rn ^rnCheckLogin.java:17: 找不到符号rn符号: 类 BaseConnrn位置: 类 net.chat.CheckLoginrn conn=new BaseConn();rn ^rnCheckLogin.java:63: 找不到符号rn符号: 类 BaseConnrn位置: 类 net.chat.CheckLoginrn BaseConn conn=null;rn ^rnCheckLogin.java:66: 找不到符号rn符号: 类 BaseConnrn位置: 类 net.chat.CheckLoginrn conn=new BaseConn();rn ^rn4 错误rnrnrn寻求帮助 rn
error LNK2005,却找不到重定义的符号....
1>QYPlugin.obj : error LNK2005: "char const * const _lpa" (?_lpa@@3PBDB) 已经在 QY.obj 中定义rn1>stdafx.obj : error LNK2005: "char const * const _lpa" (?_lpa@@3PBDB) 已经在 QY.obj 中定义rnrn我找了又找,ctrl+f不行,连百度硬盘搜索找整个硬盘都找不到这几个字符...这怎么修改啊...rnQYPlugin.h[code=C/C++]// 下列 ifdef 块是创建使从 DLL 导出更简单的rn// 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 QYPLUGIN_EXPORTSrn// 符号编译的。在使用此 DLL 的rn// 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将rn// QYPLUGIN_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的rn// 符号视为是被导出的。rn#ifdef QYPLUGIN_EXPORTSrn#define QYPLUGIN_API __declspec(dllexport)rn#elsern#define QYPLUGIN_API __declspec(dllimport)rn#endifrnrn// 此类是从 QYPlugin.dll 导出的rnclass QYPLUGIN_API CQYPlugin rnpublic:rn CQYPlugin(void);rn // TODO: 在此添加您的方法。rn;rnrnextern QYPLUGIN_API int nQYPlugin;rnrnQYPLUGIN_API int fnQYPlugin(void);[/code]rnrnQYPlugin.cpp[code=C/C++]// QYPlugin.cpp : 定义 DLL 应用程序的导出函数。rn//rn#include "stdafx.h"rn#include "QYPlugin.h"rn#include "QY.h"rn#ifdef _DEBUGrn#define new DEBUG_NEWrn#endifrnrnrn// 唯一的应用程序对象rnrnCWinApp theApp;rnrnusing namespace std;rnrnint _tmain(int argc, TCHAR* argv[], TCHAR* envp[])rnrn int nRetCode = 0;rnrn HMODULE hModule = ::GetModuleHandle(NULL);rnrn if (hModule != NULL)rn rn // 初始化 MFC 并在失败时显示错误rn if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))rn rn // TODO: 更改错误代码以符合您的需要rn _tprintf(_T("错误: MFC 初始化失败\n"));rn nRetCode = 1;rn rn elsern rn // TODO: 在此处为应用程序的行为编写代码。rn QY qy;rn IplImage* pic=qy.GetDIBitsBKgnd(FindWindow(NULL,_T("计算器")),NULL);rn cvNamedWindow("test",CV_WINDOW_AUTOSIZE);rn cvShowImage("test",pic);rn cvReleaseImage(&pic);rn rn rn elsern rn // TODO: 更改错误代码以符合您的需要rn _tprintf(_T("错误: GetModuleHandle 失败\n"));rn nRetCode = 1;rn rnrn return nRetCode;rnrn[/code]rnrnQY.H[code=C/C++]# ifndef MY_QYrn#define MY_QYrn//#include rn#include "StdAfx.h"rn//#include rn//#include rn#include "MyOPENCV.h"rn#include "IMM.h"rn#pragma comment(lib, "imm32.lib")rnclass QYrnrn public:rn QY();rn //绑定一个gdi窗口,使其成为默认窗口,调用过此函数后,截图相关函数不填写窗口句柄时默认为被绑定的窗口rn //如果目标窗口最小化,同时设置为最小化截图状态,在重复调用gdi最小化截图函数时可提高效率rn void BindMinWindow(HWND hwnd);rn //解除窗口绑定rn void UnBindMinWindow();rn //此函数用来前台截图rn //lpRect:要获取的区域,省略为全屏rn IplImage* GetDIBitsFormScreen(LPRECT lpRect=NULL);rn //此函数从后台GDI窗口(包括最小化的窗口)获取截图rn //hwnd:源窗口句柄,用BindMinWindow设置之后可省略(如不省略,以本函数的参数为准)rn //lpRect:要获取的区域,如省略,获取整个窗口rn IplImage* GetDIBitsBKgnd(HWND hwnd=NULL,const LPRECT lpRect=NULL);rn //在指定窗口激活输入法rn void MActiveIME(HWND hwnd,HKL hkl=NULL);rn private:rn //wchar_t[MAX_PATH];rn HWND CurrentHWND;rn CString GSystemPath, GPathStr ,GImeFileName ,ImeHKLString; //系统路径,当前路径,输入法文件名,输入法句柄字符串rn HKL GSysDefIme ,ImeHKL ;//默认输入法句柄,输入法句柄rn BOOL IsMinWindowReady; //窗口是否设置为最小化截图模式rn HWND hWnd;//默认情况的窗口句柄,由BindMinWindow设置rn CString MGetIMEHwndString(HKL IMEhwnd);rn //用过名称获取输入法句柄rn HKL MImeFindByName(CString lpText=_T("青云辅助输入法"));rn int InstrRev(CString src, CString tar);rn void CopyData(char *dest, const char *src, int dataByteSize,bool isConvert, int height);rn;rn#endif[/code]rn
Error:(35, 30) 错误: 找不到符号
我自定义了一个Convert,代码如下npublic final class MyConvert extends Converter.Factory n private final Gson gson;nn public static MyConvert create(Gson gson) n return new MyConvert(gson);n n public static MyConvert create()n return create(new Gson());n nn public MyConvert(Gson gson) n this.gson = gson;n nn @Overriden public Converter responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) nn TypeAdapter adapter=gson.getAdapter(TypeToken.get(type));n return super.responseBodyConverter(type, annotations, retrofit);n nnnn TypeAdapter adapter=gson.getAdapter(TypeToken.get(type));n这句代码死活编译不过去,报错信息如下:nnError:(35, 30) 错误: 找不到符号n符号: 方法 getAdapter(TypeToken)n位置: 类型为Gson的变量 gsonn其中, CAP#1是新类型变量:nCAP#1从?的捕获扩展Objectnn困扰了好几天,求大神帮忙解答~~~~
AS报错Error(303,27),找不到符号 方法 FloatMath.sin()
今天使用这个FloatMath.sin() 方法的时候报了以下错误 或者当使用此方法的时候会爆红,如下图所示: 以此记录解决方法 解决方法: 一种: 使用23以下的SDK的版本进行编译,将gradle.build文件里(包括project的gradle.build和module的gradle.build)的compileSdkVersion设为23以下。 二种: 将爆
Error:(20, 36) 错误: 找不到符号
今天在github上下载了一个Mvparms的Demo,Android Studio运行出现如下异常,make project,clean,rebuild试过了都不行,比较奇怪的是代码并没有报错,而且是github上直接down下来的,按理说不应该出错. Error:(20, 36) 错误: 找不到符号 符号: 类 DaggerMeiziComponent 位置: 程序包 com.zhy.g...
error LNK2001: 无法解析的外部符号!!求解~~
为了建立全局变量,照着网上的方法建立了一个PublicUse类实现全局变量~~结果就出了这种连接错误~~rnrn1>KeyboardDlg.obj : error LNK2001: 无法解析的外部符号 "public: void __thiscall CKeyboardDlg::OnEnChangeEdit1(void)" (?OnEnChangeEdit1@CKeyboardDlg@@QAEXXZ)rn1>KeyboardDlg.obj : error LNK2001: 无法解析的外部符号 "public: static int PublicUse::getrow" (?getrow@PublicUse@@2HA)rn1>KeyboardDlg.obj : error LNK2001: 无法解析的外部符号 "public: static int PublicUse::getline" (?getline@PublicUse@@2HA)rn1>KeyboardDlg.obj : error LNK2001: 无法解析的外部符号 "public: static int (* PublicUse::A)[4]" (?A@PublicUse@@2PAY03HA)rn1>PublicUse.obj : error LNK2001: 无法解析的外部符号 "public: static int (* PublicUse::A)[4]" (?A@PublicUse@@2PAY03HA)rn1>C:\Users\acer\Documents\Visual Studio 2010\Projects\Keyboard\Debug\Keyboard.exe : fatal error LNK1120: 4 个无法解析的外部命令
error LNK2019: 无法解析的外部符号,求解,谢!
10>正在链接...rn10>LINK : warning LNK4075: 忽略“/INCREMENTAL”(由于“/RELEASE”规范)rn10> 正在创建库 ..\..\..\..\Bin\Release\GameServer\GameServer.lib 和对象 ..\..\..\..\Bin\Release\GameServer\GameServer.exprn10>GameServerDlg.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CUGABillingThread::CUGABillingThread(class IMessagePort *)" (??0CUGABillingThread@@QAE@PAVIMessagePort@@@Z),该符号在函数 "protected: void __thiscall CMsgServerDlg::OnTimer(unsigned int)" (?OnTimer@CMsgServerDlg@@IAEXI@Z) 中被引用rn10>..\..\..\..\Bin\Release\GameServer\GameServer.exe : fatal error LNK1120: 1 个无法解析的外部命令
Java 中找不到符号的错误
class MyThread implements Runnablernrn public void run()rn rn for(int i=0;i<100;i++)rn rn System.out.println(Thread.currentThread().getName()+"的i值为:"+i);rn rn rnrnrnpublic class ThreadPoolTest1rnrn public static void main(String[] args)rn throws Exceptionrn rn ExecutorService pool=Executors.newFixedThreadPool(4); rn //ExecutorService pool = Executors.newFixedThreadPool(6);rn pool.submit(new MyThread());rn pool.submit(new MyThread());rn pool.shutdown();rn rnrnrnrn报的错误是ThreadPoolTest1.java:17: 错误: 找不到符号rn ExecutorService pool=Executors.newFixedThreadPool(4);rn ^rn 符号: 类 ExecutorServicern 位置: 类 ThreadPoolTest1rnThreadPoolTest1.java:17: 错误: 找不到符号rn ExecutorService pool=Executors.newFixedThreadPool(4);rn ^rn 符号: 变量 Executorsrn 位置: 类 ThreadPoolTest1rn2 个错误
java编译时提示找不到符号
编译时出错提示:rnrule.java:20: 找不到符号rn符号: 类 BitRulern位置: 类 com.engine.langkun.Rulern public BitRule[] bitRules = null;rn ^rnrule.java:47: 找不到符号rn符号: 类 BitRulern位置: 类 com.engine.langkun.Rulern bitRules = new BitRule[bitRuleCount];rn ^rnrule.java:49: 找不到符号rn符号: 类 BitRulern位置: 类 com.engine.langkun.Rulern BitRule r = new BitRule();rn ^rnrule.java:49: 找不到符号rn符号: 类 BitRulern位置: 类 com.engine.langkun.Rulern BitRule r = new BitRule();rn ^rn4 错误rnrn感觉jdk的设置路径应该没有问题,path,classpath,javahome都设置了,不知道还有哪里问题?新手入门,还请多多指点,谢谢!
JAVA中找不到符号的问题。
[img=https://img-bbs.csdn.net/upload/201410/26/1414327971_424089.png][/img][img=https://img-bbs.csdn.net/upload/201410/26/1414327978_28159.png][/img]rn为什么我在第一个里面加了一个捕捉异常的功能就出现符号找不到的问题??麻烦各位知道的解答一下。
Java报找不到符号错误
拜托各位大神帮忙看看rn[img=https://img-bbs.csdn.net/upload/201711/26/1511707479_674372.png][/img]rn[img=https://img-bbs.csdn.net/upload/201711/26/1511707613_602826.png][/img]rn[img=https://img-bbs.csdn.net/upload/201711/26/1511707624_685730.png][/img]rn[img=https://img-bbs.csdn.net/upload/201711/26/1511707634_983671.png][/img]rn[img=https://img-bbs.csdn.net/upload/201711/26/1511707643_946453.png][/img]rn[img=https://img-bbs.csdn.net/upload/201711/26/1511707651_589955.png][/img]rn[img=https://img-bbs.csdn.net/upload/201711/26/1511707693_133020.png][/img]
求助Java找不到符号的错误
以下是完全照着教程上的程序写的一段程序:rn1.class Circlern2.rn3. double radius, area, diameter;rn4. public void setRadius(double r) radius = r; rn5. public double getRadius() return radius; rn6. public double computeDiameter() return 2*radius; rn7. public double computeArea() return Math.PI*radius*radius; rn8. Circle(double r) radius = r; rn9.rn10.class TestCirclern11.rn12. public static void main(String args[])rn13. rn14. Circle c1 = new Circle(5);rn15. Circle c2 = new Circle();rn16. c2.setRadius(10);rn17. System.out.println("c1 Circle's Radius is: " + c1.getRadius());rn18. System.out.println("c1 Circle's Diameter is: " + c1.computeDiameter());rn19. System.out.println("c2 Circle's Area is: " + c2.computeArea());rn20. rn21.rnrn但是编译之后,出现如下错误:rnTestCircle.java:15: 找不到符号rn符号: 构造函数Circle()rn位置: 类 Circlern Circle c2 = new Circle();rn ^rn1错误rnrn照理说,类已经定义,为什么找不到符号呢?求Java高手们帮忙解答。谢谢!
Java封装时找不到符号
这是按照书上编的,检查了好久不知道哪里错了,请各位大神帮我看看, 谢谢啦rnclass Person rnrnprivate String name;rnprivate int age;rnpublic String getName()rnrn return name;rnrnpublic void setName(String stuName)rn name=stuName;rnrnpublic int getAge()rnrn return age;rnrnpublic void satAge(int stuAge)rn if(stuAge<=0)rn System.out.println("fhusih");rn elsern age=stuAge;rnrnrn public void say() rn System.out.println("年龄"+age+"姓名"+name);rnrnrnpublic class zhiyuanrnpublic static void main(String[] args)rn Person p1=new Person();rn p1.stuAge=(20);rn p1.stuName("yu");rn p1.say();rnrn[img=https://img-bbs.csdn.net/upload/201610/08/1475933750_736153.png][/img]rn[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]rnrn
找不到符号
问题描述maven项目中。在一个类(BookService)方法中实例化一个BookDao对象时报错如下。 Error:(3, 36) java: 找不到符号 符号: 类 BookDao 位置: 程序包 com.jansing.learnMybatis.dao 问题定位1.检查BookService代码,确定是否手快打错、引入错误的包类;查看对应包下有无
找不到符号?
从网上拷下来一个源码,编译的时候三个错误都是找不到符号,哪位高手帮我改一下?rnD:\code\TransformExample.java:25: 找不到符号rn符号: 类 ImagePanern位置: 类 TransformExamplern ImagePane pane;rn ^rn
找不到符号!
/*rn * To change this template, choose Tools | Templatesrn * and open the template in the editor.rn */rnrnpackage mail;rnrn/**rn *rn * @author Administratorrn */rnimport java.io.File;rnimport java.io.UnsupportedEncodingException;rnimport java.net.MalformedURLException;rnimport java.net.URL;rnimport java.util.ArrayList;rnimport java.util.Date;rnimport java.util.Properties;rnrnimport javax.activation.DataHandler;rnimport javax.activation.FileDataSource;rnimport javax.mail.Address;rnimport javax.mail.MessagingException;rnimport javax.mail.Session;rnimport javax.mail.Transport;rnimport javax.mail.internet.AddressException;rnimport javax.mail.internet.InternetAddress;rnimport javax.mail.internet.MimeBodyPart;rnimport javax.mail.internet.MimeMessage;rnimport javax.mail.internet.MimeMultipart;rnimport javax.mail.internet.MimeUtility;rnrnrnrnrn rnrn rnrnrnpublic class Mail rn/** 发件方式 - 普通发送 */rnfinal public static int TO = 0;rn/** 发件方式 - 抄送 */rnfinal public static int CC = 1;rn/** 发件方式 - 密件抄送 */rnfinal public static int BCC = 2;rnrn/** 邮件相关信息 - SMTP 服务器 */rnprivate String mailSMTPHost = null;rn/** 邮件相关信息 - 邮件用户名 */rnprivate String mailUser = null;rn/** 邮件相关信息 - 密码 */rnprivate String mailPassword = null;rn/** 邮件相关信息 - 发件人邮件地址 */rnprivate String mailFromAddress = null;rn/** 邮件相关信息 - 邮件主题 */rnprivate String mailSubject = "";rn/** 邮件相关信息 - 邮件发送地址 */rnprivate Address[] mailTOAddress = null;rn/** 邮件相关信息 - 邮件抄送地址 */rnprivate Address[] mailCCAddress = null;rn/** 邮件相关信息 - 邮件密件抄送地址 */rnprivate Address[] mailBCCAddress = null;rn/** 邮件相关信息 - 邮件正文(复合结构) */rnprivate MimeMultipart mailBody = null;rnrnpublic Mail() rn mailBody = new MimeMultipart();rnrnrn/**rn * 设置 SMTP 服务器rn * @param strSMTPHost 邮件服务器名称或 IPrn * @param strUser 邮件用户名rn * @param strPassword 密码rn */rnpublic void setSMTPHost(String strSMTPHost, String strUser,rn String strPassword) rn this.mailSMTPHost = strSMTPHost;rn this.mailUser = strUser;rn this.mailPassword = strPassword;rnrnrn/**rn * 设置邮件发送地址rn * @param strFromAddress 邮件发送地址rn */rnpublic void setFromAddress(String strFromAddress) rn this.mailFromAddress = strFromAddress;rnrnrn/**rn * 设置邮件目的地址rn * @param strAddress 邮件目的地址列表, 不同的地址可用;号分隔rn * @param iAddressType 邮件发送方式 (TO 0, CC 1, BCC 2) 常量已在本类定义rn * @throws AddressExceptionrn */rnpublic void setAddress(String strAddress, int iAddressType) throwsrn AddressException rn switch (iAddressType) rn case Mail.TO: rn ArrayList alAddress = StringHelper.split(strAddress, ';');rn mailTOAddress = new Address[alAddress.size()];rn for (int i = 0; i < alAddress.size(); i++) rn mailTOAddress[i] = new InternetAddress( (String) alAddress.get(i));rn rn break;rn rn case Mail.CC: rn ArrayList alAddress = StringHelper.split(strAddress, ';');rn mailCCAddress = new Address[alAddress.size()];rn for (int i = 0; i < alAddress.size(); i++) rn mailCCAddress[i] = new InternetAddress( (String) alAddress.get(i));rn rn break;rn rn case Mail.BCC: rn ArrayList alAddress = StringHelper.split(strAddress, ';');rn mailBCCAddress = new Address[alAddress.size()];rn for (int i = 0; i < alAddress.size(); i++) rn mailBCCAddress[i] = new InternetAddress( (String) alAddress.get(i));rn rn break;rn rn rnrnrn/**rn * 设置邮件主题rn * @param strSubject 邮件主题rn */rnpublic void setSubject(String strSubject) rn this.mailSubject = strSubject;rnrnrn/**rn * 设置邮件文本正文rn * @param strTextBody 邮件文本正文rn * @throws MessagingExceptionrn */rnpublic void setTextBody(String strTextBody) throws MessagingException rn MimeBodyPart mimebodypart = new MimeBodyPart();rn mimebodypart.setText(strTextBody, "GBK");rn mailBody.addBodyPart(mimebodypart);rnrnrn/**rn * 设置邮件超文本正文rn * @param strHtmlBody 邮件超文本正文rn * @throws MessagingExceptionrn */rnpublic void setHtmlBody(String strHtmlBody) throws MessagingException rn MimeBodyPart mimebodypart = new MimeBodyPart();rn mimebodypart.setDataHandler(new DataHandler(strHtmlBody, "text/html;charset=GBK"));rn mailBody.addBodyPart(mimebodypart);rnrnrn/**rn * 设置邮件正文外部链接 URL, 信体中将包含链接所指向的内容rn * @param strURLAttachment 邮件正文外部链接 URLrn * @throws MessagingExceptionrn * @throws MalformedURLExceptionrn */rnpublic void setURLAttachment(String strURLAttachment) throwsrn MessagingException, MalformedURLException rn MimeBodyPart mimebodypart = new MimeBodyPart();rn mimebodypart.setDataHandler(new DataHandler(new URL(strURLAttachment)));rn mailBody.addBodyPart(mimebodypart);rnrnrn/**rn * 设置邮件附件rn * @param strFileAttachment 文件的全路径rn * @throws MessagingExceptionrn * @throws UnsupportedEncodingExceptionrn */rnpublic void setFileAttachment(String strFileAttachment) throwsrn MessagingException, UnsupportedEncodingException rn File path = new File(strFileAttachment);rn if (!path.exists() || path.isDirectory()) rn return;rn rn String strFileName = path.getName();rn MimeBodyPart mimebodypart = new MimeBodyPart();rn mimebodypart.setDataHandler(new DataHandler(new FileDataSource(rn strFileAttachment)));rn // modified by zord @ 2003/6/16 to support Chinese File Namern // mimebodypart.setFileName(strFileName);rn mimebodypart.setFileName(MimeUtility.encodeText(strFileName));rn // end of modifyrn mailBody.addBodyPart(mimebodypart);rnrnrn/**rn * 邮件发送(一次发送多个地址, 优点速度快, 但是有非法邮件地址时将中断发送操作)rn * @throws MessagingExceptionrn */rnpublic void sendBatch() throws MessagingException rn Properties properties = new Properties();rn properties.put("mail.smtp.host", this.mailSMTPHost);rn Session session = Session.getInstance(properties, null);rn MimeMessage mimemessage = new MimeMessage(session);rn mimemessage.setFrom(new InternetAddress(this.mailFromAddress));rn if (mailTOAddress != null) rn mimemessage.addRecipients(javax.mail.Message.RecipientType.TO,rn this.mailTOAddress);rn rn if (mailCCAddress != null) rn mimemessage.addRecipients(javax.mail.Message.RecipientType.CC,rn this.mailCCAddress);rn rn if (mailBCCAddress != null) rn mimemessage.addRecipients(javax.mail.Message.RecipientType.BCC,rn this.mailBCCAddress);rn rn mimemessage.setSubject(this.mailSubject);rn mimemessage.setContent(this.mailBody);rn mimemessage.setSentDate(new Date());rn Transport transport = session.getTransport("smtp");rn transport.connect(this.mailSMTPHost, this.mailUser, this.mailPassword);rn Transport.send(mimemessage);rn System.out.println("已向下列邮箱发送了邮件");rn if (mailTOAddress != null) rn for (int i = 0; i < mailTOAddress.length; i++) rn System.out.println(mailTOAddress[i]);rn rn rn if (mailCCAddress != null) rn for (int i = 0; i < mailTOAddress.length; i++) rn System.out.println(mailCCAddress[i]);rn rn rn if (mailBCCAddress != null) rn for (int i = 0; i < mailTOAddress.length; i++) rn System.out.println(mailBCCAddress[i]);rn rn rnrnrnrn以上是我在网上搜到的一个发邮件的mail类,main()方法就不贴出来了。运行的时候报错:rnD:\My Documents\NetBeansProjects\Mail\src\mail\Mail.java:116: 找不到符号rn符号: 变量 StringHelperrn位置: 类 mail.Mailrn ArrayList alAddress = StringHelper.split(strAddress, ';');rnrn是不是缺少import org.hibernate.util.StringHelper这个包啊?请高手指点,谢谢...rnrn
找不到符号???
[code=Java]rnimport java.awt.*;rnrnimport javax.swing.*;rnrnpublic class theNoteBook extends JFramernrn public theNoteBook()rn super("MyNoteBook");rn setUpUICompenents();rn setUpEventListener();rn setVisible(true);rn rnrn private void setUpUICompenents()rn setSize(400,500);rnrn JFrame JF = new JFrame();rn JMenuBar JMB = new JMenuBar();rn setJMenuBar(JMB);rnrn JMenu fileMenu = new JMenu("file");rn JMenuItem New = new JMenu("new");rn JMenuItem Open = new JMenu("open");rn JMenuItem Close = new JMenu("close");rn JMenuItem Save = new JMenu("save");rn JMenuItem SaveAs = new JMenu("save as");rn JMB.add(fileMenu);rn fileMenu.add(New);rn fileMenu.add(Open);rn fileMenu.add(Close);rn fileMenu.add(Save);rn fileMenu.add(SaveAs);rnrn Open.addActionListener(rn new ActionListener() rn public void actionPerformed(ActionEvent e)rn openFile();rn rn rn );rn rnrn public void openFile()rnrn private void setUpEventListener()rn setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn rnrn public static void main(String [] args)rn new theNoteBook();rn rnrn[/code]rnrn为什么在 new ActionListenre 这里提示找不到符号啊???
“找不到符号”?
String [][] Parameters = "" , "" ; rn rn for ( int i = 0 ; i < Params.length ; i ++ ) rn rn Parameters [ 1 ] [ i ] = Params [ i ] ; rn rn rn Parameters [ 0 ] [ Params.length - 1 ] = ParameterDirection.Output ; rn rn其中ParameterDirection.java rn rnpublic class ParameterDirection rn rn /** Creates a new instance of ParameterDirection */ rn public ParameterDirection() rn rn rn public final static String Input = "0" ; rn public final static String Output = "1" ; rn public final static String InputOutput = "2" ; rn public final static String ReturnValue = "3" ; rn rn rn rn而且可以访问ParameterDirection类 rn rn总是提示“UserDAL.java:38: 找不到符号”: rn符号: 变量 ParameterDirection rn位置: 类 UserDAL rn Parameters [ 0 ] [ Params.length - 1 ] = ParameterDirection.Output ; rn1 错误 rn生成失败(总时间:3 秒) rn rn为何?
找不到符号、
public class MyIfElsernrn public static void main(String args[])rn rn int grade=0;rn System.out.println("你的成绩是多少?(0-100)?");rn tryrn rn BufferedReader br=new BufferedReader(new InputStreamReader(System.in));rn grade=Integer.parseInt(br.readLine());rn catch(IOExcepetion ex)rnrn。。。rn。。。rn。。。rnrnrnrn编译之后提醒 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));找不到符号 怎么回事啊- -
错误 17 error LNK2001: 无法解析的外部符号 _PyExc_ImportError
错误 17 error LNK2001: 无法解析的外部符号 _PyExc_ImportError
Error:(4, 25) java: 找不到符号符号:类 xxx位置:程序包 xxx.xxx
idea运行java程序的时候报错,提示:“Error:(4, 25) java: 找不到符号符号:类 xxx位置:程序包 xxx.xxx”。我当时出现这种情况是因为用idea的maven打了jar包,之后运行程序出现上述错误。 解决方法:用maven中的“clean”清理掉刚才打的jar包之后就不会报错了。 ...