小记:1、pom多模块打包 2、读取txt文件,按行读取或全部 3、curl常见使用 4、前端传递参数与后端@responseBody映射参数名大小写保持一致

1、pom多模块打包

mvn -e clean install -Dmaven.test.skip=true -pl :${module} -am
其中${module}替换为子模块的模块名。

2、读取txt文件

//按行读取存list
public static List<String> read(){
        ArrayList<String> arrayList = new ArrayList<>();
        try {
            File file = new File("D:\\item.txt"); //绝对路径
            BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String str;
            while ((str = bf.readLine()) != null) {
                arrayList.add(str);
            }
            bf.close();
            input.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return arrayList;
    }
    //读取所有存入string
    public static String read(){
        StringBuffer buffer = new StringBuffer();
        BufferedReader bf= new BufferedReader(new FileReader(System.getProperty("user.dir")+"/doc/demo.txt")); //相对路径,当前项目根目录下的doc文件下demo.txt
        String s;
        while((s = bf.readLine())!=null){//使用readLine方法,一次读一行
            buffer.append(s.trim());
        }
        String demo = buffer.toString();
    }

3、curl常见使用

post请求,参数是data,值为hello:
curl -X POST -d "data=hello" http://localhost:13201/test
post请求,参数是对象:
curl -X POST -H"Content-Type:application/json" http://localhost:13201/test -d '{ "name":"test", "type":"0", "num":3 }'

4、前端传递参数与后端@responseBody映射参数名大小写保持一致

有时候前端传递全大写字段名,但是后端springboot默认首字母小写,导致参数传递丢失,可以添加如下注解解决。

@JSONField(name="TEXT")
private String TEXT;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值