zoukankan      html  css  js  c++  java
  • 异常处理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配置文件也已经配啦,,,,,,
    求大神指点
    本人目前处于学习阶段,各位大神多多提宝贵的建议!
  • 相关阅读:
    多层神经网络与C++实现
    反向传导算法的推导
    sizeof()和strlen()的区别与联系
    Pascal’s Triangle
    Multiply Strings
    spring boot 数据源 配置
    spring boot 静态资源。。
    spring boot 配置 beetl 视图解析器
    spring 使用junit
    spring aspectj 注解
  • 原文地址:https://www.cnblogs.com/FanSunny/p/4738985.html
Copyright © 2011-2022 走看看