高手指点下,实现是没办法了!!!发了几次贴了,还是没解决.
报的错误:
An error occurred at line: 4 in the jsp file: /add_ok.jsp
Generated servlet error:
The method newsInsert(String) in the type newsdb is not applicable for the arguments (String, String, String, String)
页面代码:
<%
newsdb in=new newsdb();
String list=null;
String title=null;
String text=null;
String time=null;
list=request.getParameter( "list ");
title=request.getParameter( "title ");
text=request.getParameter( "text ");
time=request.getParameter( "time ");
int cs=in.newsInsert(list,title,text,time);
if (cs> 0)
{
out.print( "插入成功 ");
}
else
{
out.print( "插入失败 ");
}
%>
方法的代码:
public int newsInsert(String list1,String title1,String text1,String time1)
{
try
{
con = DriverManager.getConnection(url,user,password);
Statement stmt=con.createStatement();
String sql= "insert into data(list,title,text,time) values( ' "+list1+ " ', ' "+title1+ " ', ' "+text1+ " ', ' "+time1+ " ') ";
int cs=stmt.executeUpdate(sql);
return cs;
}
catch (SQLException ex)
{
ex.printStackTrace();
}
return 0;
}
注:把SQL语句如果写在页面中是可以插手的,但是写到类中,有报错!!请高手指点下,我该如何是好!
[解决办法]
public int newsInsert(String list1,String title1,String text1,String time1)
你这个方法的申明是public int newsInsert(String ,String ,String ,String)
还是public int newsInsert(String )阿
[解决办法]
你贴出你的完整代码来看看
[解决办法]
代码不全,看不出来
[解决办法]
上面一段代码改成:
list=(String)request.getParameter( "list ");
title=(String)request.getParameter( "title ");
text=(String)request.getParameter( "text ");
time=(String)request.getParameter( "time ");
试试
------解决方案--------------------
up