java.lang.NumberFormatException: For input string: “method:{0}.{1}“处理

When writing a test, use the placeholder MessageFormat.format to output an error.
insert image description here
Check my statement carefully.

 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()));

I found that the format does not allow the form {…{0}…}, then I changed it to…{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()));

run successfully

Mistakes like this are very small, and can only be avoided with more experience

Guess you like

Origin blog.csdn.net/weixin_44077556/article/details/108342472