java.lang.NumberFormatException: 入力文字列の場合: "method:{0}.{1}"

テストを作成するときは、プレースホルダー MessageFormat.format を使用してエラーを出力します。
ここに画像の説明を挿入
ステートメントを注意深く確認してください。

 System.out.println(MessageFormat.format(
                "{method:{0}.{1},params:{2},user:[id:{3},username:{4}],ip:{5},dateTime:{6},operationCode:{7},type:{8},creater:{9},requestUrl:{10}}"
                ,cla,method,json.toString(),userid,username,ip,new Date().getTime(),"ceshi",request.getMethod(),"ceshiCreater",request.getRequestURL()));

この形式では {…{0}…} という形式が許可されていないことがわかり、それを…{0}… に変更しました。

System.out.println(MessageFormat.format(
                "method:{0}.{1},params:{2},user:[id:{3},username:{4}],ip:{5},dateTime:{6},operationCode:{7},type:{8},creater:{9},requestUrl:{10}"
                ,cla,method,json.toString(),userid,username,ip,new Date().getTime(),"ceshi",request.getMethod(),"ceshiCreater",request.getRequestURL()));

正常に実行されました

このような間違いは非常に小さなものであり、経験を積むことでのみ回避できます。

おすすめ

転載: blog.csdn.net/weixin_44077556/article/details/108342472