我在捕获发送到服务器的 PUT 请求时遇到问题。
这些是我的方法:
@RequestMapping(method= RequestMethod.GET)
public String getCity(@PathVariable(value="cid") String cid, @RequestParam(value="State") Integer state, Model model) {
System.out.println("get request");
return "index";
}
@RequestMapping(method= RequestMethod.PUT)
public String putCity(@PathVariable(value="cid") String cid, @RequestParam(value="State") Integer state, Model model) {
System.out.println("put request");
return "index";
}
当我跟踪调用时,我的 PUT 请求是由 GET 方法处理的,而不是由我的类中的 PUT 方法处理的。在屏幕上,它始终读取为“获取请求”。我检查了浏览器日志并确认他们发送了正确的 PUT 请求,所以我想我在这里错过了一些 Spring 配置,但我不知道它是什么..
有人可以帮忙吗?
谢谢。
编辑:带有类的附加代码:
@Controller
@RequestMapping(value="/retail/{cid}/master/city")
public class City {
@RequestMapping(value="/foo1", method= RequestMethod.GET)
public String getCity(@PathVariable(value="cid") String cid, @RequestParam(value="State") Integer state, Model model) {
System.out.println("get request");
return "index";
}
@RequestMapping(value="/foo2", method= RequestMethod.PUT)
public String putCity(@PathVariable(value="cid") String cid, @RequestParam(value="State") Integer state, Model model) {
System.out.println("put request");
return "index";
}
}
编辑2:
抱歉,我在检查日志时似乎不太彻底。我两次发现这个警告。
WARNING: Error in annotation processing: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
有什么想法如何解决这个问题吗?