NutzCN Logo
问答 问一个关于适配器的问题~
发布于 2588天前 作者 yangeejgs 1671 次浏览 复制 上一个帖子 下一个帖子
标签:

这是方法头:

@IocBean
@At("/sysaspx")
@Ok("json")
@Fail("http:500")
@Encoding(input = "UTF-8", output = "UTF-8")
public class RecordModule extends BaseModule {

    private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(RecordModule.class);

    @At("/apk")
    @AdaptBy(type = PairAdaptor.class)
    @GET
    public NutMap addrecord(@Param("MachineId") String MachineId, @Param("RecordList") List<Record> recordList) {
        LOGGER.info("MachineId : {},插入Record{}", MachineId, recordList);
        NutMap re = new NutMap();
...

想用get请求去请求他,这样写url会报400。。求正确的请求方式,
RecordList是Record对象集合

http://localhost:8888/sysaspx/apk.aspx?MachineId=001056&RecordList=[{"RecID":"1","ItemIndex0":"0","ItemIndex":"0","SubItemIndex":"0","ItemName":"农残","ChannelID":"1","SampleName":"大白菜","AbsorbX":"0.1","CalcResult":"0","TestLimit":"<50","CheckResult":"1","TxtResult":"合格","UintName":"抑制率","Uint":"%","Supplier":"检测单位未设置","ProducePlace":"被检单位未设置","UploadFlag":"0","CheckPerson":"检测员未设置","CodeId":"0","TestTime":"11:50:44.000","TestDate":"2016-07-26","NcItemName":"null","NcValue":"0","Temperature":"null","Humidity":"null","GPS":"null","Result":"null","TypeName":"null","DTI_ID":"T05230163083947084"}]
4 回复

RecordList要urlencode之后才能拼入URL, 另外,这种数据应该作为body发送,而不是放到URL里面

补充一个,这样的数据请求不应该用~~GET~~方式请求,应该改用**POST**然后结合兽老大说的,把数据放到BODY传入,完成!

@elkan1788 其实我。。。POST已经搞定的。。。

客户说他设备只能get 好气呀~~

@yangeejgs 哈,这个真是有点无语啦,GET方式也不太安全呀!

添加回复
请先登陆
回到顶部