controller接收httpclient请求
来源:互联网 发布:ios 仿淘宝详情页 编辑:程序博客网 时间:2024/04/30 14:47
- 如果controller放在现有的项目中, 要绕过登录验证
- 要responseBody返回xml需要配置applicationContext-mvc配置文件增加
<mvc:annotation-driven/>
- 实体类加xml注解
@Controller@RequestMapping("appTestVpn")public class AppTestVpnController extends BaseController{ @RequestMapping(value="testVpn",method=RequestMethod.POST) @ResponseBody public Coffee testVpn() { try { BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(),Charset.forName("GBK"))); StringBuilder sb1 = new StringBuilder(); String line = null; while ((line = in.readLine()) != null) { sb1.append(line); } String jstr=sb1.toString(); //读取客户端发送来的信息 System.err.println(jstr); } catch (IOException e) { e.printStackTrace(); } System.err.println("ssss"); Coffee coffee = new Coffee("蓝山", 100); return coffee; }}
import javax.xml.bind.annotation.XmlElement;import javax.xml.bind.annotation.XmlRootElement;@XmlRootElement(name = "coffee")public class Coffee { String name; int quanlity; public String getName() { return name; } @XmlElement public void setName(String name) { this.name = name; } public int getQuanlity() { return quanlity; } @XmlElement public void setQuanlity(int quanlity) { this.quanlity = quanlity; } public Coffee(String name, int quanlity) { this.name = name; this.quanlity = quanlity; } public Coffee() { }}
阅读全文
0 0
- controller接收httpclient请求
- spring-05-Controller如何接收请求参数
- JAVA发送HttpClient请求及接收请求结果过程
- JAVA发送HttpClient请求及接收请求结果过程
- JAVA发送HttpClient请求及接收请求结果过程
- JAVA发送HttpClient请求及接收请求结果过程
- JAVA发送HttpClient请求及接收请求结果过程
- HttpClient的POST请求示例及返回接收
- httpclient发送get请求并接收相应数据
- 使用HttpClient发送请求并接收返回信息
- JAVA发送HttpClient请求及接收请求结果处理为JSONOBJCET过程
- HttpClient请求
- HttpClient请求
- HttpClient请求
- httpClient 请求
- httpClient请求
- HttpClient请求
- HttpClient请求
- Android中ConvenientBanner的使用
- GC垃圾回收算法总结
- 在苹果电脑上安装 Qt 5.2
- Effective C++之二:构造/析构/赋值运算
- Array(数组)10个常用方法
- controller接收httpclient请求
- 华为云专家分享架构师的基本功之管理篇
- 招聘黑话大全,能听懂证明你是历经磨难的老司机
- 天池新人实战赛o2o优惠券使用预测三
- DSP Flag篇
- 在vue中使用jquery
- crontab
- Android 表单逻辑校验方案的探讨
- 数据库应用排查优化