异常处理1

这是action中的插入的方法

public void doInsertStudent() throws IOException{
this.ajaxRun(new AjaxRun() {
@Override
public void run(BaseResultVO ajaxRsp) throws Exception {
StudentModel model = getModel();
Map<String, String> returnMap = new HashMap<String, String>();
// ajaxRsp 返回 object 必须设置下面为true
ajaxRsp.setOutputResultObjOnly(true);
try {
if (model.getId() == null) {
throw new BusiException("学生id不能为空");
}
if (model.getName() == null) {
throw new BusiException("学生姓名不能为空");
}
if (model.getPass() == null) {
throw new BusiException("密码不能为空");
}
if (model.getEmail()== null) {
throw new BusiException("邮箱不能为空");
}
if (model.getGrade()== null) {
throw new BusiException("年级不能为空");
}
System.out.println(model.getId());
System.out.println(model.getEmail());
System.out.println(model.getPass());
System.out.println("1111111111111111111111111插入学生列表");
studentService.Insert(model);

// System.out.println("学生添加成功");
returnMap.put("code", Dict.ReturnCode.SUCCEEDED);
returnMap.put("msg", "添加学生成功!");

当哪一项不填也会给出一个提示(xxx不能为空);插入操作的时候,也能获取到model中相应的值,就是studentService.Insert(model);没有执行;给出的输出结果是:

%3Cvalue%3E%7B%7D%3C%2Fvalue%3E------转码后是:<value>{}</value>
不能给出“学生添加成功”的提示
怎么与后台数据库建立联系,,而且该配的xml配置文件也已经配啦,,,,,,
求大神指点
posted @ 2015-08-18 11:42  FanSunny  阅读(403)  评论(1编辑  收藏  举报