在下面的代码中,我试图对特殊字符进行编码
package hello;
//import java.io.UnsupportedEncodingException;
import org.owasp.esapi.ESAPI;
import org.owasp.esapi.Encoder;
import org.owasp.esapi.errors.EncodingException;
public class HelloWorld {
public static void main(String[] args) {
// TODO Auto-generated method stub
//System.out.println("Hello Worldadndh");
// System.out.println("ESAPI.accessacController found: "
// + ESAPI.accessController());
String encodedString = encodeForXML("comma underscore hyphen, _ - & () %");
System.out.println("The encoded string is "+encodedString);
}
public static String encodeForXML(String str)
{
return ESAPI.encoder().encodeForXML(str);
}
}
o/p 是
The encoded string is comma underscore hyphen, _ - & () %
是否有一些设置需要编码,_ -?谢谢你。