java 斜杠转义问题

当我把一段  路径字符串  替换到前台接受的时候   字符串中的 \  消失了

例如   apache-tomcat-8.5.27\webapps\bgb\imgPath    

 \    消失不见

解决方法:将字符串中的"\"替换成"\\"

例如:

String pic_Path=" apache-tomcat-8.5.27\webapps\bgb\imgPath   ";

String pic_Page1=pic_Page.replaceAll("\\\\","\\\\\\\\");

再把pic_Path1传过去

猜你喜欢

转载自blog.csdn.net/qq_41566772/article/details/81663328