我目前正在开发一个现有项目(java版本:1.7.0,使用Spring MVC框架版本:3.1.4),我们只在一个URI中找到了这个@RequestMapping(value = "/site/apps/{question}.json", method = RequestMethod.GET)
public @ResponseBody ServiceResponse moreUsers(
@PathVariable("question") final Question question,
@RequestParam(value = "sort", required = false) final String sort,
final HttpServletRequest request, final Model model)
问题特定的控制器类,如果你们中的任何人已经遇到过这个错误,我将非常感谢你们是如何修复/解决它的?谢谢!
代码(java控制器类的提取部分):
ERROR Error executing request: /site/apps/52440.json
org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public com.project.infrastructure.service.ServiceResponse com.project.plugins.controllers.SiteAppController.moreUsers(com.project.models.node.Question,java.lang.String,javax.servlet.http.HttpServletRequest,org.springframework.ui.Model)]; nested exception is java.lang.IllegalStateException: **Could not find @PathVariable [question] in @RequestMapping**
错误输出我们的tomcat日志(catalina.out文件):
public class Client{
@Id
@Column(columnDefinition = "CHAR(11)")
private String cpf;
@ManyToMany(cascade = CascadeType.ALL)
private List<Address> addresses;
//get set
}
我们已经研究过的内容:
答案 0 :(得分:0)
在你的方法处理程序中尝试使用{question} pathVariable作为int,假设你在Question JavaBean&amp;中有int questionid字段。尝试在方法处理程序中构造Question JavaBean ..
@RequestMapping(value = "/site/apps/{question}.json", method = RequestMethod.GET)
public @ResponseBody ServiceResponse moreUsers(
@PathVariable("question") Integer question,
@RequestParam(value = "sort", required = false) final String sort,
final HttpServletRequest request, final Model model){
Question Q=questionservice.getQuestion(question);
}