如何访问请求来自不同url-s的POST数据到一个控制器方法,例如我有/countries
& /countries/{id}
URL,它对第一个非常有用,我的代码是如何将post方法应用于春季的所有请求映射
@RequestMapping(value = {"/{id}", "/{id}/"}, method = RequestMethod.GET)
public String getCountry(@PathVariable(value = "id", required = true) int id,ModelMap model) {
}
@RequestMapping(method = RequestMethod.POST)
public String deleteCountry(ModelMap model,HttpServletRequest request) {
}
当我尝试从第二URL请求POST数据我得到
HTTP Status 405 - Request method 'POST' not supported
,因为我没有这个映射POST方法这是可预期的,但只要我愿意,成为o的一种方法ne映射我的代码会太丑蚂蚁太可怕了,我能用什么解决方案?
我通过URL中的regexp找到了一个解决方案,这只是一种可能的方式吗? – Nesquik27
“丑陋可怕” - 你必须以某种方式提供*实现*,对吗?这是如何使你的代码糟糕的? – chrylis