我在捕获发送到服务器的 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 方法处理的。在屏幕上,它总是读为“get request”。我检查了浏览器日志并确认他们发送了正确的 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";
}
}
EDIT2:抱歉,我在检查日志时似乎没有很彻底。我两次收到此警告。
警告:注释处理中的错误:java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
任何想法如何解决这个问题?