我对 Spring@RequestMapping
注释的行为感到困惑。在下面的代码中,test()
被映射到"/test"
并被test_test()
映射到"/test/test/test"
. 这里发生了什么?如果我想映射test()
到,我该怎么办"/test/test"
?
package com.mvc.spring;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value = "/test")
public class Test {
@RequestMapping(value = "/test", method = RequestMethod.GET)
String test() {
return "test";
}
@RequestMapping(value = "/test/test", method = RequestMethod.GET)
String test_test() {
return "test";
}
}