日期:2014-05-17  浏览次数:20860 次

试一个javabean和数据库连接的例子,但是出现了如下错误,不知其解。求教。。。
我所有的源代码都编译了,根据包的定义分层放在目录下。

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

An error occurred at line: 9 in the jsp file: /javabeandemo1/emp_insert_do.jsp
Emp cannot be resolved to a type
6: <% request.setCharacterEncoding("GBK"); %>
7: <body>
8: <%
9: Emp emp = new Emp() ;
10: emp.setEmpno(Integer.parseInt(request.getParameter("empno"))) ;
11: emp.setEname(request.getParameter("ename")) ;
12: emp.setJob(request.getParameter("job")) ;


An error occurred at line: 9 in the jsp file: /javabeandemo1/emp_insert_do.jsp
Emp cannot be resolved to a type
6: <% request.setCharacterEncoding("GBK"); %>
7: <body>
8: <%
9: Emp emp = new Emp() ;
10: emp.setEmpno(Integer.parseInt(request.getParameter("empno"))) ;
11: emp.setEname(request.getParameter("ename")) ;
12: emp.setJob(request.getParameter("job")) ;


An error occurred at line: 16 in the jsp file: /javabeandemo1/emp_insert_do.jsp
DAOFactory cannot be resolved
13: emp.setHiredate(new SimpleDateFormat("yyyy-MM-dd").parse(request.getParameter("hiredate"))) ;
14: emp.setSal(Float.parseFloat(request.getParameter("sal"))) ;
15: try{
16: if(DAOFactory.getIEmpDAOInstance().doCreate(emp)){
17: %>
18: <h3>雇员信息添加成功!</h3>
19: <%


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Emp类文件如下:
Java code
package cn.mldn.lxh.vo ;
import java.util.Date ;
public class Emp {
    private int empno ;
    private String ename ;
    private String job ;
    private Date hiredate ;
    private float sal ;
    public void setEmpno(int empno){
        this.empno = empno ;
    }
    public void setEname(String ename){
        this.ename = ename ;
    }
    public void setJob(String job){
        this.job = job ;
    }
    public void setHiredate(Date hiredate){
        this.hiredate = hiredate ;
    }
    public void setSal(float sal){
        this.sal = sal ;
    }
    public int getEmpno(){
        return this.empno ;
    }
    public String getEname(){
        return this.ename ;
    }
    public String getJob(){
        return this.job ;
    }
    public Date getHiredate(){
        return this.hiredate ;
    }
    public float getSal(){
        return this.sal ;
    }
}


------解决方案--------------------
楼主好霸气
------解决方案--------------------
明显的路劲 问题 ; 这样的问题需要你自己解决......
------解决方案--------------------
cannot be resolved to a type
勒个去,这个问题还真常见。
我的异常网推荐解决方案: