HTTP Status 405 - JSPs only permit GET POST or HEAD的解决方案

1.出错的代码

@RequestMapping(value="/testRest/{id}",method=RequestMethod.PUT)
	public String  testRestPut(@PathVariable("id") String id){
		System.out.println("text Rest put:"+id);
		return SUCCESS;
	}

2.出错的原因

发起的请求是个RESTFul风格的请求,调用了RESTFul风格的PUT方法。但是controller里testRestPUT返回的success字符串被映射到success.jsp。因此spring认为这应该是个JSP接口,且JSP接口仅仅支持GET方法和POST方法。所以系统提示提示了这个错误。 --------------------- 本文来自 zhangchao19890805 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/zhangchao19890805/article/details/51587029?utm_source=copy

3.解决方案

@RequestMapping(value="/testRest/{id}",method=RequestMethod.PUT)
	@ResponseBody()
	public String  testRestPut(@PathVariable("id") String id){
		System.out.println("text Rest put:"+id);
		return SUCCESS;
	}
	

  

猜你喜欢

转载自www.cnblogs.com/QYou/p/9699630.html
今日推荐