Spring mvc Spring mvc 3.1无法解析URI模板
我有一个配置了URI模板模式的控制器类。但是,当我从另一个控制器类重定向到此控制器时,它无法找到此处理程序方法 我在日志中看到一个错误,上面写着“RequestMappingHandlerMapping-没有找到/path2/2的处理程序方法”,然后是“在DispatcherServlet中找不到URI为[/path2/2]的HTTP请求的映射”Spring mvc Spring mvc 3.1无法解析URI模板,spring-mvc,Spring Mvc,我有一个配置了URI模板模式的控制器类。但是,当我从另一个控制器类重定向到此控制器时,它无法找到此处理程序方法 我在日志中看到一个错误,上面写着“RequestMappingHandlerMapping-没有找到/path2/2的处理程序方法”,然后是“在DispatcherServlet中找不到URI为[/path2/2]的HTTP请求的映射” @Controller @RequestMapping("/path1") public class Controller1 { @Reques
@Controller
@RequestMapping("/path1")
public class Controller1 {
@RequestMapping (method = MethodRequest.POST)
public String postMethod() {
// some logic
return "redirect:/path2/" + 2;
}
}
@Controller
@RequestMapping("/path2/${id}")
public class Controller2 {
@RequestMapping(method=RequestMethod.GET)
public ModelAndView getMethod(@PathVariable("id") long id) {
return new ModelAndView("some jsp");
}
}
如果我将Controller2类上的RequestMapping更改为“/path2/”并重定向到该url,重定向工作正常。是否有人可以提供建议?
我在web.xml中配置了DispatcherServlet,在servlet上下文文件中配置了InternalResourceViewResolver
提前感谢!!语法是
@RequestMapping("/path2/{id}")
不是
啊!!花了几个小时调试这个。谢谢!!
@RequestMapping("/path2/${id}")