将以下 jar 添加到我的 WEB-INF 中的 lib 文件夹中:
我添加的代码片段是:
从模型对象:
public class UserDetails {
@Pattern(regexp="(^0-9}*")
private String userName;
@Size(min=2,max=10)
private String firstName;
private String lastName;
private String emailId;
private ArrayList<String> accountType;
private ArrayList<String> gender;
@Size(min=2,max=10)
private Long accountNo;
Run Code Online (Sandbox Code Playgroud)
FromController 类:
@RequestMapping(value = "/UserAccount.html", method = RequestMethod.POST)
public ModelAndView userAccountForm(
@Valid @ModelAttribute("user") UserDetails user,
BindingResult result) {
if (result.hasErrors()) {
ModelAndView model1 = new ModelAndView("LoginForm");
return model1;
}
ModelAndView model1 = new ModelAndView("UserAccount");
return model1;
}
Run Code Online (Sandbox Code Playgroud)
我的调度程序 …
我正在开发一个应用程序,其中LoginForm.jsp并UserRegistration.jsp会导致UserAccount jsp网页上的特定action.In LoginForm当用户按下"登录"按钮- > UserAccount形式是当输入并提交信息displayed.In放在userRegistration表- >显示UserAccount形式.以下是请求时的控制器代码UserAccount.html
@RequestMapping(value="/UserAccount.html", method = RequestMethod.POST)
public ModelAndView userAccountForm(@Valid @ModelAttribute("user") UserDetails user,BindingResult result) {
if(result.hasErrors())
{ System.out.println(result.getAllErrors());
ModelAndView model1=new ModelAndView("UserRegistration");
return model1;
}
// User validation
System.out.println(user.getAccountType());
userDAO.create(user);
ModelAndView model1 = new ModelAndView("UserAccount");
return model1;
}
Run Code Online (Sandbox Code Playgroud)
loginForm.jsp中
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<body>
<h1
style="background-color: green; color: Yellow; padding: 10px; text-align: center;">Mybank
Online Login</h1>
<form:errors path="user.*" />
<form action="/MyBankProject/UserAccount.html" method="post">
<div
style="background-color: yellow; color: black; padding: 10px; text-align: …Run Code Online (Sandbox Code Playgroud)