您现在的位置:首页 >> 前端 >> 内容

addFieldError无法匹配的报错

时间:2017/10/7 10:15:00 点击:

  核心提示:public void validate() { if(getName()== null || getName().length()==0) { addFieldError(newbookna...
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)

Tags:AD DD DF FI 
作者:网络 来源:junruitian