提交 a70cb10c 编写于 作者: C Calvin

修正prepare接口在新版MVC上的bug,在createForm提交时,如果有hidden input...

修正prepare接口在新版MVC上的bug,在createForm提交时,如果有hidden input value且值为空时出错,因此将required=false 改为 defaultValue="-1"
上级 e5b8e304
......@@ -45,8 +45,8 @@ public class ProfileController {
* 因为仅update()方法的form中有id属性,因此仅在update时实际执行.
*/
@ModelAttribute
public void getUser(@RequestParam(value = "id", required = false) Long id, Model model) {
if (id != null) {
public void getUser(@RequestParam(value = "id", defaultValue = "-1") Long id, Model model) {
if (id != -1) {
model.addAttribute("user", accountService.getUser(id));
}
}
......
......@@ -62,8 +62,8 @@ public class UserAdminController {
* 因为仅update()方法的form中有id属性,因此仅在update时实际执行.
*/
@ModelAttribute
public void getUser(@RequestParam(value = "id", required = false) Long id, Model model) {
if (id != null) {
public void getUser(@RequestParam(value = "id", defaultValue = "-1") Long id, Model model) {
if (id != -1) {
model.addAttribute("user", accountService.getUser(id));
}
}
......
......@@ -51,7 +51,7 @@ public class TaskController {
@Autowired
private TaskService taskService;
@RequestMapping(value = "")
@RequestMapping(method = RequestMethod.GET)
public String list(@RequestParam(value = "page", defaultValue = "1") int pageNumber,
@RequestParam(value = "page.size", defaultValue = PAGE_SIZE) int pageSize,
@RequestParam(value = "sortType", defaultValue = "auto") String sortType, Model model,
......@@ -112,9 +112,9 @@ public class TaskController {
* 所有RequestMapping方法调用前的Model准备方法, 实现Struts2 Preparable二次部分绑定的效果,先根据form的id从数据库查出Task对象,再把Form提交的内容绑定到该对象上。
* 因为仅update()方法的form中有id属性,因此仅在update时实际执行.
*/
@ModelAttribute()
public void getTask(@RequestParam(value = "id", required = false) Long id, Model model) {
if (id != null) {
@ModelAttribute
public void getTask(@RequestParam(value = "id", defaultValue = "-1") Long id, Model model) {
if (id != -1) {
model.addAttribute("task", taskService.getTask(id));
}
}
......
......@@ -103,8 +103,8 @@ public class UserController {
* 因为仅update()方法的form中有id属性,因此仅在update时实际执行.
*/
@ModelAttribute
public void getUser(@RequestParam(value = "id", required = false) Long id, Model model) {
if (id != null) {
public void getUser(@RequestParam(value = "id", defaultValue = "-1") Long id, Model model) {
if (id != -1) {
model.addAttribute("user", accountService.getUser(id));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册