日期:2014-05-18  浏览次数:20576 次

关于servlet中response的sethead和addhead
response.sethead("name","liudehua1");
response.addhead("name","liudehua2");
response.sethead("name","liudehua3");

第三行代码,会把前面两个name都替换掉,还是只会替换掉其中的一个呢。

------解决方案--------------------
自己写一个servlet测试以下。
URL url = new URL("http://localhost:8080/apps/Servlet/Test");
URLConnection uc = url.openConnection();
Map<String, List<String>> headers = uc.getHeaderFields();
System.out.println(headers);
一目了然了。
------解决方案--------------------
自己写代码试一下