5.让tomcat支持SSI
修改web.xml,设置一个servlet即可.只要将相关的注释去掉即可.
::ssi命令只能在后缀名为shtml的文件中才能被正确执行,它与JSP命令不能同时被执行,
即它不能放在JSP文件中执行.
因为:从web.xml中的servletMapping中就可以看出.
::To use the SSI servlet, you also need to rename the
$CATALINA_HOME/server/lib/servlets-ssi.renametojar file
to $CATALINA_HOME/server/lib/servlets-ssi.jar
class EncodeTest
{
public static void main(String[] args) throws Exception
{
String a ="碁";
//a.getBytes()利用平台的gbk编码.
String b = new String(a.getBytes(),"ISO8859_1");
//这时候c就是gb2312编码的,输出即可.
String c = new String(a.getBytes(),"gb2312");
System.out.println("b="+b+" c="+c);
//因为b已经是iso编码的,这时用iso编码,然后再用gbk解码
String bb = new String(b.getBytes("ISO8859_1"),"GBK");
//采用平台默认gbk进行解码字节数组.
String bbb = new String(b.getBytes("ISO8859_1"));
//因为a是gbk解码,用gb编码,再用gbk解码.
String cc = new String(a.getBytes("gb2312"),"GBK");