My Spring MVC可以调用普通的控制器函数,但不能调用包含path变量的函数。
我有两个链接 / myapp / projects 和 / myapp / project / {name}
第一个链接在我的控制器中运行良好,但第二个链接无法调用我的控制器功能。 web.xml应该是正确的。由于错误如下:
我的web.xml
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/projects</url-pattern>
<url-pattern>/project/*</url-pattern>
</servlet-mapping>
我的控制员:
@Controller
public class ProjectsController {
static final Logger LOGGER = Logger.getLogger(ProjectsController.class);
@RequestMapping(value = "/projects", method = RequestMethod.GET)
public String getInstances(Model model)
throws Exception {
System.out.println("=====projects====");
return "release-projects";
}
@RequestMapping(value = "/project/{name}", method = RequestMethod.GET)
public String getDetails(@PathVariable("name") String name, Model model) throws Exception {
System.out.println("=====project details====");
model.addAttribute("model", "111");
return "project_details";
}
}