美文网首页
HttpServletRequest and HttpServl

HttpServletRequest and HttpServl

作者: 农民工__乔Young | 来源:发表于2019-02-10 15:19 被阅读0次

API

HttpServletRequest and HttpServletResponse两个接口由容器实现,不需要码农实现,码农只需要知道两接口的方法使用。

请求参数的获取
getParameter("parameterName")返回String;
getParameterValues("parameterName")返回String[]

response:
设置响应内容类型
response.setContentType("MIME type");//必须首先设置
Common MIME types:
text/html application/pdf video/quicktime application/java image/jpeg
application/jar application/octet-stream application/x-zip
获取字符流
PrintWriter writer = response.getWriter();
writer.println("some text and html");
获取字节流
OutputStream out = response.getOutputStream();
out.write(aByteArray);
获取到流后,可以像普通I/O一样进行流操作

相关文章

网友评论

      本文标题:HttpServletRequest and HttpServl

      本文链接:https://www.haomeiwen.com/subject/jdfxeqtx.html