public void validate()
{
if(getname()== null || getname().length()==0)
{
addfielderror("newbookname","用户名不为空");
}
else{
try{
db mysql = new db();
username = mysql.returnlogin(request);
rs = mysql.selectfri(request, username, this.getname());
if(rs.next())
{
addfielderror("name","已经存在");
}
}catch(sqlexception ex)
{
ex.printstacktrace();
}
}
//if(getisbn()==null|| getisbn().length()==0)
//addfielderror("","bunengweikong");
}
public string execute() throws exception{
db mysql = new db();
username = mysql.returnlogin(request);
string fri = mysql.insertfri(request, username, this.getname(), this.getprice(), this.getdate(), this.getauthor(), this.getpublisher(), this.getisbn(),this.getnumber());
if(fri.equals("ok"))
{
message = success;
}
else if(fri.equals("one"))
{
message = input;
}
return message;
}
上部分message =success;和addfielderror报错无法匹配
the method addfielderror(string, string) is undefined for the type addfriaction
主要原因使在public class 定义的时候没有增加exteds 和implements
修改:
public class addfriaction extends actionsupport implements servletrequestaware {
之后就可以正常调用了
void com.opensymphony.xwork2.actionsupport.addfielderror(string fieldname, string errormessage)
孤独是种安全感i