当我运行http://localhost:8080/crm/add.jsp时,提示如下错误: org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 34 in the jsp file: /add.jspGenerated servlet error: [javac] Compiling 1 source fileD:\Tomcat 4.1\work\Standalone\localhost\crm\add_jsp.java:104: non-static method executeInsert(java.lang.String) cannot be referenced from a static context test1.executeInsert(sql); ^ 1 error 我想大概是web.xml的错误,用到了servlet,请问:那位师兄能够提供一份完整的web.xml文件(加注释),在下感激不尽,并赠分50。谢谢
查询<Context path="/examples"
将下面的话这段话上面
<Context path="/cao" docBase="D:/cao" debug="0"
reloadable="true" crossContext="true"/>
path网页路径
docBase文档地址
http://localhost:8080/cao/
即可访问
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 34 in the jsp file: /add.jspGenerated servlet error:
[javac] Compiling 1 source fileD:\Tomcat 4.1\work\Standalone\localhost\crm\add_jsp.java:104: non-static method executeInsert(java.lang.String) cannot be referenced from a static context
test1.executeInsert(sql);
^
1 error
我想大概是web.xml的错误,用到了servlet,请问:那位师兄能够提供一份完整的web.xml文件(加注释),在下感激不尽,并赠分50。谢谢
什么web.xml错误啊
不要想当然
明显是你的test1类里面的方法executeInsert(sql)不是静态的方法
//增加记录
public void executeInsert(String sql)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeInsert(sql);
}
catch(SQLException ex)
{
System.err.println("testbean.executeInsert:"+ex.getMessage());
}
}
还请师兄多多请教