如何解决如何重置表单 Java Spring
我想从“成功注册页面”移回后重新设置表单
background-color
我在 /registration_success 上有“返回”按钮
我试过@Controller
public class MainController {
@GetMapping("/")
public String homePage(Model model) {
return "index";
}
@GetMapping("/registration")
public String showForm(Model model) {
Student user = new Student();
model.addAttribute("student",user);
return "registration";
}
@PostMapping("/registration")
public String submitForm(@Valid Student student,BindingResult bindingResult) {
System.out.println(student.toString());
if (bindingResult.hasErrors()) {
return "registration";
} else {
return "registration_success";
}
}
}
,但没有任何反应。单击“Enter”后,我无法重置表单.. 为什么以及如何修复它?
document.getElementById('FullName').value = '';
解决方法
您的表单有一个 ID reg_form
这将重置整个表单 document.getElementById("reg_form").reset();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。