shuijibaobao

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
 

增强for循环

一般for循环:

    int[] num ={1,2,3,4,5,6};
    for(int i=0;i<num.length ; i++){
        System.out.println("元素:"+ num[i]);
    }

增强for循环:

    int[] num ={1,2,3,4,5,6};
    for(int i :num){//集合或数组a :数组名称
         numSystem.out.println("元素:"+ i);
    }
    //遍历对象数组,通过对象访问对象的属性值
    public static void testobject(student [] students){
        for(student student :students){
            System.out.println("姓名:"+ student.name + ",年龄:"+ student.age);
        }
    }

@ApiOperation

@ApiOperation() 是一个注解,通常用于描述 RESTful API 的操作,特别是在使用 Swagger 或 OpenAPI 规范来描述和文档化 API 时。这个注解是 Swagger/OpenAPI 的一部分,Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。

当你使用 @ApiOperation() 注解时,你通常是为了给某个特定的 API 方法或端点提供元数据描述。这些描述可以帮助 API 的使用者更好地理解和使用 API。

try catch

try catch 中的return语句

没有异常发生:

如果try块中的代码成功执行且没有发生异常,那么try块中的return语句会被执行,并且该return语句会立即终止方法的执行,返回指定的值。catch块中的代码在这种情况下不会被执行。

public int method() { 
    try { 
        // some code 
        return 42; 
        // 如果没有异常,这行代码会被执行并返回42 
    }catch (Exception e) {
        // 不会执行到这里 
        return 0; 
    } 
}

异常发生在try块中:

如果try块中的代码引发了异常,并且这个异常与catch块中的参数类型匹配,那么catch块中的代码会被执行。如果catch块中包含return语句,那么这个return语句会立即终止方法的执行,并返回指定的值。

public int method(){ 
    try { 
        // some code that throws an exception throw new Exception(); 
        return 42; // 这行代码不会被执行 
    } catch (Exception e) {
         // 如果有异常,这行代码会被执行并返回0 
        return 0; 
    } 
}

多个catch块:

如果try块中的代码引发了异常,并且这个异常与多个catch块中的参数类型匹配,那么会执行第一个匹配的catch块中的代码。同样,如果catch块中有return语句,那么它会立即终止方法的执行。

public int method() { 
    try { 
        // some code that throws an exception throw new IOException(); 
    } catch (IOException e) {
        // 如果有IOException,这行代码会被执行并返回1 
        return 1; 
    } catch (Exception e) {
             // 这行代码不会被执行,因为上面的catch已经匹配了IOException 
             return 0; 
    } 
}

finally块:

如果try-catch语句后面跟着一个finally块,那么无论是否发生异常,finally块中的代码总会被执行。但是,请注意,finally块中的代码不会改变try或catch块中return语句的返回值(除非在finally块中发生了异常或使用了某些特殊机制,如System.exit()

public int method() {
    int result; 
    try { 
        // some code 
        result = 42; 
        return result; 
        // 这行代码会先执行,但返回值会被暂存 
    } catch (Exception e) { 
        result = 0; return result; 
        // 同理,返回值会被暂存 
    } finally {
         // 这段代码总会执行,但不会影响前面return的值 
         System.out.println("Finally block executed"); 
    } 
    // 这里的代码不会被执行,因为return已经终止了方法 
}

动态sql

<if test = "params.projettType != null and params.projectType != ''">
    and ps.projectType in 
    <foreach collection = "params.ProjectType" item = "item" open = "(" close=")" separatoe = ",">
        #{item}
    </foreahch>
</if>

判断作用

从数据库取数据并传给前端

有Controller层、DTO VO、Mapper层、Service层(接口实现类)、xml
img

项目运行时bug

img
解决上述问题的方法
img

拆分包

使其分开显示,取消勾选 Compact Middle Packages
img

posted on   水吉z  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现
 
点击右上角即可分享
微信分享提示