【发布时间】:2014-11-25 09:36:10
【问题描述】:
我在一个类中有一个方法,一旦点击“下一步”按钮,它就会返回一个 jsp 文件。但它只是擦除当前页面中的数据并返回当前页面。
这是方法
@RequestMapping(value = "/addQuestion", method = RequestMethod.POST)
public String addQuestion(Model model, @RequestParam(value="question", required = true) String theQuestion , @RequestParam(value="questionId", required = true) Integer questionId, @RequestParam(value="category", required = true) String category, @RequestParam(value="correctAnswer", required = true) String correctAnswer) throws SQLException{
ViewController viewController = new ViewController();
viewController.createQuestion(questionId, theQuestion, category, correctAnswer);
model.addAttribute("question", new Question());
return "qFour";
}
它应该返回 qFour.jsp 但它只返回 addQuestion.jsp 这是它当前所在的页面
【问题讨论】:
-
qFour是否被正确返回? -
返回后放什么没关系。即返回“qFour”返回“qOne”返回“qFive”。没有出现预期的jsp
-
根据stackoverflow.com/a/7386124/3898076,你的语法是正确的,所以还有一些问题。
-
我可以提供哪些其他代码来找到问题的解决方案?
-
首先,尝试调试您的代码并找出您的
addQuestion方法是否被调用?