为什么在linux上,response.sendRedirect还有问题?
我写了一个servlet,其中要将错误信息转发:
url = String url = "error?text=" + java.net.URLEncoder.encode("错误");
res.sendRedirect(url);
在error中,用URLDecoder.decode(text),即可得到中文。
这个servlet在win2000上正常工作,但在linux redhat 7.2中就不行。
我用了new String(str.getBytes(text), "ISO-8859-1","GB2312")等方法,但没有用。
结果地址栏中应当是B2%E2%CA%D4%D2%B3%C3%E6这样的串才对。
但现在是:????或是%3F%3F%3F%3F%3F%3F%3F%3F。
我的servlet engine是domino 5.09. linux redhat 7.2
jre是1.1.8,我把1.3的URLDecoder解压出来用了。
javac TestServlet.java -encoding GB2312
也用了。
而我如果是用一个href来实现,url = "error?text=...."。
linux下,在error中只需要用new String(str.getBytes(text), "ISO-8859-1","GB2312")转换即可。中文就好了。但这个sendRedirect有问题。
不知道是否和操作系统有关,我的redhat是英文,是不是需要汉化?
哪位高手指教。在下感激涕零!