获取requestBody中的内容
来源:互联网 发布:mac设置邮箱无法验证 编辑:程序博客网 时间:2024/06/08 14:14
/** * @Description: requestBody的处理 * @userName: jiangyu * @date: 2015年11月11日 上午9:15:38 * @param request * @param response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) { try { request.setCharacterEncoding("UTF-8"); int size = request.getContentLength(); InputStream is = request.getInputStream(); byte[] reqBodyBytes = readBytes(is, size); //获取请求body中的内容 String res = new String(reqBodyBytes); request.setAttribute("fetchUrl", res); } catch (Exception e) { e.printStackTrace(); } } public static final byte[] readBytes(InputStream is, int contentLen) { if (contentLen > 0) { int readLen = 0; int readLengthThisTime = 0; byte[] message = new byte[contentLen]; try { while (readLen != contentLen) { readLengthThisTime = is.read(message, readLen, contentLen - readLen); if (readLengthThisTime == -1) {// Should not happen. break; } readLen += readLengthThisTime; } return message; } catch (IOException e) { // Ignore e.printStackTrace(); } } return new byte[] {}; }
0 0
- 获取requestBody中的内容
- beego获取requestbody里的内容
- 获取JPassword中的内容
- 获取iframe中的内容
- SpringMVC中的 @RequestBody
- 如何获取内容中的数字
- 获取网页中的内容(CDHtmlDialog)
- 获取textedit框中的内容
- Qt获取QTextEdit中的内容
- 获取tinyMCE编辑器中的内容
- simpleCursorAdapter中的listview获取内容
- html 获取文本框中的内容
- php 获取表单中的内容
- jq获取iframe中的内容
- @RequestBody获取Json请求数据
- springmvc中的@Responsebody与@RequestBody
- SpringMVC中的@RequestBody与@ResponseBody
- @RequestBody
- Android下载APK并自动安装
- POJ 3348 (凸包)
- 学习 SpiderMonkey
- 【DuiLib入门基础】九宫格corner属性详细解释
- JDBC连接数据库(oracle)操作
- 获取requestBody中的内容
- recyclerview 滚动状态
- linux信号汇总大全
- c# 如何使用DllImport
- matlab学习笔记(三)---图像的代数运算
- 【Unity实用小方法】生成随机颜色
- 使用 Spring 2.5 基于注解驱动的 Spring MVC
- 在openshift.redhat.com建的xpush项目无法访问报403
- 7,运算符的一些注意点