405 method not allowed

1 篇文章 0 订阅

用Postman测一个接口的时候,返回了405,百度搜,都说把post请求改成get就可以了,但是,代码是这样的 。(公司前辈写的,我只是按要求改了中间的一个小细节)

@GetMapping("getPlayHistoryInfo")
	public String getLivePlayHistoryInfo(
			@RequestParam("usertoken") String usertoken,
			@RequestParam("userid") String userid, 
			@RequestParam("cpspid") int cpspid,
			@RequestParam("parent") int parent, 
			@RequestParam("videoencryption") int videoencryption,
			@RequestParam("action") int action) {
		JSONObject object = new JSONObject();
		BookMarkBean liveVodBean = new BookMarkBean();
		liveVodBean.setUserId(userid);
		liveVodBean.setMediaType(2);
		try {
			if (action == 0) {
				List<LiveBean> list = bookMarkService.getBookMarkInfoByUserId(liveVodBean);
				List<LiveBean> liveList = getChannelList(list, usertoken, parent, videoencryption, cpspid, userid);
				object.put("playInfo", JSONArray.fromObject(liveList).toString());
			} else if (action == 1) {
				List<VodBean> vodlList = bookMarkService.getVodInfoByUserId(liveVodBean);
				List<VodBean> vodList = getProgramList(vodlList, usertoken, parent, videoencryption, cpspid, userid);
				object.put("playInfo", JSONArray.fromObject(vodList).toString());
			}
			object.put("returnCode", 0);
		} catch (Exception e) {
			e.printStackTrace();
			object.put("returnCode", -1);
		}
		return object.toString();
	}

我一看这代码,不是post啊,找了蛮久蛮久蛮久,然后分步输出,才发现是getProgramList方法这里报的错,跟进去,发现这个方法里面又调用了另外一个方法,再跟进去! 

public String getVodPlayUrl(String usertoken, int pid, String userid, int seriesId) {
		String url = "http://vod/getVodPlayUrl?usertoken=" + usertoken + "&pid=" + pid + "&mediaType=1" + "&userid=" + userid + "&seriesId=" + seriesId;
		return  restTemplate.postForEntity(url, String.class, String.class).getBody();
	}

终于发现post在哪了,把最后一句return 换成

return restTemplate.getForEntity(url, String.class).getBody();

就能正常走下去了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值