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

[复制链接]
查看11 | 回复2 | 2021-1-27 07:15:45 | 显示全部楼层 |阅读模式
局域网内本地服务器发送至其他服务器:
前端$.ajax请求json报文至后台(servlet)服务器request无法得到json参数,求大神!
前端代码:functiondoPost(){
varperson={
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'
};
varoption={
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);
}
后端:
publicvoidservice(HttpServletRequestrequest,HttpServletResponseresponse){
}
InputStreamin=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(WindowsNT6.1;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/55.0.2883.87Safari/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(WindowsNT6.1;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/64.0.3282.186Safari/537.36
access-control-request-headers=content-type,x-requested-with
accept=*/*
accept-encoding=gzip,deflate
accept-language=zh-CN,zh;q=0.9

分 -->
回复

使用道具 举报

千问 | 2021-1-27 07:15:45 | 显示全部楼层
request.getAttribute("")试试这个呢~
回复

使用道具 举报

千问 | 2021-1-27 07:15:45 | 显示全部楼层
1、使用request.getParameter("...")试试
2、content-type要设置成json吧!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行