异步请求jquery action
package com.tarena.action;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import com.tarena.dao.CostDao;
import com.tarena.entity.Condition;
import com.tarena.entity.Cost;
@Controller
public class CheckNameAction {
@Resource
private CostDao costDao;
private String name;// 资费名
private Map<String, Object> info = new HashMap<String, Object>();// 提示信息
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getInfo() {
return info;
}
public void setInfo(Map<String, Object> info) {
this.info = info;
}
public String check(){
//异步查询资费名称是否存在
Condition con = new Condition();
if(name!=null){
con.setName(name);
Cost cost = costDao.findByName(con);
if (cost == null) {
// 没有找到资费,说明名称没有重复
info.put("success", true);
info.put("message", "有效的资费名称");
} else {
// 找到了资费数据,说明资费名重复了
info.put("success", false);
info.put("message", "资费名已经存在了");
}
return "succ";
}
return "su";
}
}