我是靠谱客的博主 务实魔镜,这篇文章主要介绍解决:java.util.UnknownFormatConversionException: Conversion = ‘>‘,现在分享给大家,希望可以做个参考。

code:

复制代码
1
2
3
4
5
6
@Test void test() { String regex = "<%%s%>"; String test = String.format(regex, "测试"); log.info(">>> 测试 = {}", test); }

error:

 原因:String.format() 格式化字符串输出时把“%>”识别成了转换符

解决:

方法1:

        code:

复制代码
1
2
3
4
5
6
@Test void test() { String regex = "<%%%s%%>"; String test = String.format(regex, "测试"); log.info(">>> 测试 = {}", test); }

        结果:>>> <%测试%>
方法2:

        code:

复制代码
1
2
3
4
5
6
@Test void test() { String regex = "<%%s%s>"; String test = String.format(regex, "测试","%"); log.info(">>> 测试 = {}", test); }

        结果:>>> <%测试%>

方法3:      

        code:

复制代码
1
2
3
4
5
6
@Test void test() { String regex = "<%%s%>"; String test = regex.replaceFirst("%s","测试"); log.info(">>> 测试 = {}", test); }

        结果:>>> <%测试%>

最后

以上就是务实魔镜最近收集整理的关于解决:java.util.UnknownFormatConversionException: Conversion = ‘>‘的全部内容,更多相关解决:java.util.UnknownFormatConversionException:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(70)

评论列表共有 0 条评论

立即
投稿
返回
顶部