我有简单的控制器,必须做一些任务。 任务是DB中对象的更改状态。 从jsp我发送两个参数bur当我点击按钮发送我有的参数" 404找不到"
我的控制器方法:
@Controller
@RequestMapping(value = "/tests")
public class TestController {
private TestInterfaceService testService;
@Autowired(required = true)
@Qualifier(value = "testService")
public void setTestService(TestInterfaceService testService) {
this.testService = testService;
}
@RequestMapping("/review/{id}")
public String editTest(@PathVariable("id") int id, Model model) {
model.addAttribute("test", this.testService.getTestById(id));
model.addAttribute("questions", this.testService.getListQuestionsById(id));
return "review";
}
@RequestMapping(value = "/choise/{id}/{status}/", method = RequestMethod.GET)
public String changeStatus(@PathVariable("id") int id, @PathVariable("status") String status, Model model) {
this.testService.getTestById(id).setStatus(status);
this.testService.updateTest(this.testService.getTestById(id));
model.addAttribute("test", this.testService.getTestById(id));
model.addAttribute("questions", this.testService.getListQuestionsById(id));
return "review";
}
}
我的jsp页面按钮:
<div class="container">
<div class="btn-group">
<button type="button" class="btn btn-primary">Choise</button>
<button type="button" class="btn btn-primary dropdown-toggle"
data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a
href="<c:url value='/tests/choise/${test.id}/${"Approve"}' />">Approve</a></li>
<li><a
href="<c:url value='/tests/choise/${test.id}/${"Return"}' />">Return
author</a></li>
<li><a
href="<c:url value='/tests/choise/${test.id}/${"Refuse"}' />">Refuse</a></li>
</ul>
</div>
</div>