2013年9月2日星期一

About the servlet response of sethead and addhead

response.sethead ("name", "liudehua1");
response.addhead ("name", "liudehua2");
response.sethead ("name", "liudehua3");

The third line of code , would have replaced the two previous name , or just replace one yet.
------ Solution ---------------------------------------- ----
to write a servlet to test the following .
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);
glance .
------ Solution ---------------------------------------- ----
write their own code to try
------ For reference only -------------------------- -------------
someone to help answer the following questions Why , thank you.
------ For reference only -------------------------------------- -
setHeader will reset the value of the same key , if not new . addHeader will correspond to the same key value into an array.

没有评论:

发表评论