前端$.ajax请求json报文至后台(servlet)服务器request无法得到json参数

ly176042889 2018-03-06 09:48:35
局域网内本地服务器发送至其他服务器:

前端$.ajax请求json报文至后台(servlet)服务器request无法得到json参数,求大神!

前端代码: function doPost(){
var person = {
ServiceCode:'DHE002',
cus_id:'23333333',
cus_name:'杭州市XX橡胶股份有限公司',
if_renew:'1',
apply_amt:'1200000',
apply_term:'12',
work_addr:'XX路XX号',
contacts:'老何',
contact_number:'13333333333'
};
var option = {
url: 'http://127.0.0.1:8088/cmis/CrcbHttpFromICF',
type: 'POST',
data: JSON.stringify(person),
dataType: 'html',
contentType: 'application/x-www-form-urlencoded',
success: function (result) { alert(result); }
};
$.ajax(option);
}

后端:

public void service(HttpServletRequest request, HttpServletResponse response) {
}

InputStream in = request.getInputStream(); //无法取到参数



图片为后端request值,其中:content-length = -1

本地发本地没有问题,可以收到参数:content-length = 224



求大神!!!!!!!!!!

本地发本地 headers对象值为:
=== MimeHeaders ===
host = 127.0.0.1:8088
connection = keep-alive
content-length = 224
accept = text/html, */*
origin = http://127.0.0.1:8088
x-requested-with = XMLHttpRequest
user-agent = Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
content-type = application/json
referer = http://127.0.0.1:8088/cmis/getLocalHttpTestPage.do?EMP_SID=HDDVITEEBSGPEYAYFZBSDZGZJACVFRGDDFEOGBCU&menuId=httptest
accept-encoding = gzip, deflate, br
accept-language = zh-CN,zh;q=0.8
cookie = cstrees.cus=midkhslsq_treenode; cotrees.cus=; cotrees.wdgzt=; topic=xtheme-green.css; skin=default-green.css; extCss=2; mainSkin=infoGreen.css; cotrees.xtpz=; JSESSIONID=4A9D7E38B16E2B1C892B5675DFD8A315; cstrees.xtpz=httptest_treenode; __guid=96992031.3003261057912573000.1517106957683.7715; monitor_count=11

本地发服务器headers对象值为:
=== MimeHeaders ===
host = 172.16.1.54:8088
connection = keep-alive
access-control-request-method = POST
origin = http://127.0.0.1:8080
user-agent = Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
access-control-request-headers = content-type,x-requested-with
accept = */*
accept-encoding = gzip, deflate
accept-language = zh-CN,zh;q=0.9
...全文
617 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Miracle1216 2018-03-08
  • 打赏
  • 举报
回复
1、使用request.getParameter("...")试试 2、content-type要设置成json吧!
Sunyiban 2018-03-07
  • 打赏
  • 举报
回复
request.getAttribute("")试试这个呢~

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧