按照这个:

@RequestMapping(value = {"/abcd/id={id}","/abcd?id={id}"}, method = RequestMethod.GET)

public ModelAndView test(@PathVariable("id") String id) {

我在我的代码中指定了上面两种类型的值。当我们调用 uri 时,前者工作正常,但后来没有被识别(即)@RequestMapping 没有识别?(问号)
作为传递的参数的一部分。

最佳答案

您应该使用 @RequestParam 作为方法参数获取 URL 上的参数。

@RequestMapping(value = "/abcd", method = RequestMethod.GET)
public void test(@RequestParam String id) {
    // your code here
}

关于spring-mvc - RequestMapping 未将 ?(问号)标识为通过 java REST Call 传递的参数的一部分,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11468600/

10-11 04:24
查看更多