java - Spring Boot 2.0.5 是否不运行请求参数
问题描述
我正在尝试学习 spring boot 2.0 的基础知识,当我尝试将待办事项添加到我的待办事项列表应用程序时,我不断收到白标签错误。Spring Boot 2.0 是否仍然使用请求参数或已弃用?因为即使我尝试删除一个待办事项,我仍然会收到一个白标签错误,说没有传递 id。
我的待办事项控制器:
public class TodoController {
@Autowired
TodoService service;
@RequestMapping(value = "/list-todos", method = RequestMethod.GET)
public String showTodos(ModelMap modelMap) {
String name = (String) modelMap.get("name");
modelMap.put("todos", service.retrieveTodos(name));
return "list-todos";
}
@RequestMapping(value = "/add-todo", method = RequestMethod.GET)
public String showAddTodoPage(ModelMap model) {
return "todo";
}
@RequestMapping(value = "/add-todo", method = RequestMethod.POST)
public String addTodo(ModelMap model, @RequestParam String desc) {
service.addTodo((String) model.get("name"), desc, new Date(), false);
return "redirect:/list-todos";
}
@RequestMapping(value = "/delete-todo", method = RequestMethod.GET)
public String deleteTodo(@RequestParam("id") int id, ModelMap model) {
model.put("id", id);
service.deleteTodo(id);
return "redirect:/list-todos";
}
}
我的待办事项 JSP:
<html>
<head>
<title>add-todo</title>
</head>
<body>
<h1>Add Todo Page for ${name}</h1>
<form action="Post" method="post">
<input type="text" name="desc">
<br>
<input type="submit">
</form>
</body>
</html>
解决方案
推荐阅读
- windows - 构建批处理程序来监控、创建和删除电池日志
- mysql - 将 REPLACE 与 CHAR(160) 一起使用将返回十六进制值
- visual-studio - Visual Studio 2017 使用 #else 指令丢失了智能感知和着色
- c++ - n皇后问题的程序仅适用于n<=10,即使它应该适用于所有n
- c++ - c ++对对象的排序向量,编译错误要求运算符“=”
- javascript - 如何从 ASP.NET MVC 中的另一个视图修改 share layout.cshtml 中的 image.OnClick?
- python - 如何使用python使用列作为索引将多个csv文件连接成一个csv文件
- python - python中是否有任何方法可以自动更正单列excel文件的多行中的拼写错误?
- javascript - 亲子关系不正常
- javascript - 页面加载时自动按键