Form gives Nulls when submitted - java

I am using Spring MVC + thymeleaf and when I am submitting my form it gives me all the time validation error(Null) in the binding result. Any advise would be appreciated! Thanks!
Error message
"Field error in object 'createForm' on field 'authorId': rejected value [null]; codes [NotNull.createForm.authorId,NotNull.authorId,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [createForm.authorId,authorId]; arguments []; default message [authorId]]; default message [may not be null]"
#NotNull
#Size(min= 2, max = 100, message = "your title should be between 2 and 100 symbols")
private String title;
#NotNull
#Size(min = 2, message = "Please fill your message")
private String content;
#DateTimeFormat(pattern = "yyyy-mm-dd")
private Date date;
#NotNull
private String authorId;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getId() {
return authorId;
}
public void setId(String authorId) {
this.authorId = authorId;
}
}
And my HTML
<form id="create-form" method="post" th:object="${createForm}">
<div><label for="title">Title:</label></div>
<input id="title" type="text" name="title" th:value="*{title}"/>
<span class="formError" th:if="${#fields.hasErrors('title')}" th:errors="*{title}">Invalid title</span>
<div><label for="content">Content:</label></div>
<textarea name="content" rows="30" cols="100" id="content" th:value="*{content}"></textarea>
<span class="formError" th:if="${#fields.hasErrors('content')}" th:errors="*{content}">Invalid content</span>
<div><label for="date">Date:</label></div>
<input id="date" type="date" name="date" th:value="*{date}"/>
<span class="formError" th:if="${#fields.hasErrors('date')}" th:errors="*{date}">Invalid date</span>
<div><label for="authorId">Author ID:</label></div>
<input id="authorId" type="text" name="authorId" th:value="*{authorId}"/>
<span class="formError" th:if="${#fields.hasErrors('id')}" th:errors="*{authorId}">Invalid id</span>
<br/>
<br/>
<div><input type="submit" value="Create"/></div>
</form>

As written in the comment to the question:
Annotation #NotNull won't protect you from null. It's your own contract with you and other developers working on this code that there can't be null there.
This means that you have to validate data by yourself. There are two approaches. You can create AuthorTO which will allow nulls and then create Author if and only if there are no unexpected nulls or validate on front-end side.

Related

Null fields in Thymeleaf form using Spring Boot, other fields fine

I'm relatively new to Spring Boot. Currently, I'm making a Spring Boot application with user registration system but I've run into an issue. Some of the fields in a form are registering as ‘null’ on the back end, despite the request being posted correctly.
I have a HTML/ Thymeleaf form which submits 8 fields to create a 'User' object. This is the form:
<form th:action="#{/users/register_attempt}" th:object="${user}"
method="post" style="max-width: 600px; margin: 0 auto;">
<div class="m-3">
<div class="form-group row">
<label class="col-4 col-form-label">DOB: </label>
<div class="col-8">
<input type="text" th:field="*{dob}" class="form-control" th:required="required" />
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">First Name: </label>
<div class="col-8">
<input type="text" th:field="*{name}" class="form-control" th:required="required" />
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">Surname: </label>
<div class="col-8">
<input type="text" th:field="*{surname}" class="form-control" th:required="required" />
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">PPSN: </label>
<div class="col-8">
<input type="text" th:field="*{ppsn}" class="form-control" th:required="required" />
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">Address: </label>
<div class="col-8">
<input type="text" th:field="*{address}" class="form-control" th:required="required" />
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">Phone Number: </label>
<div class="col-8">
<input type="number" th:field="*{phone}" class="form-control" />
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">E-mail: </label>
<div class="col-8">
<input type="email" th:field="*{email}" class="form-control" th:required="required" />
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">Password: </label>
<div class="col-8">
<input type="password" th:field="*{password}" class="form-control"
required minlength="6" maxlength="10" th:required="required"/>
</div>
</div>
<div>
<button type="submit" class="btn btn-primary">Sign Up</button>
</div>
</div>
</form>
And here is the model that the form code is meant to mimic:
public class User {
#Id
#GeneratedValue
private Long id;
#NotBlank
private String dob;
#NotBlank
private String name;
#NotBlank
private String surname;
#NotBlank
private String ppsn;
#NotBlank
private String address;
#NotBlank
private String phone;
#NotBlank
#Column(unique = true)
private String email;
private String nextApptId;
private String dose1Date;
private String dose2Date;
private String lastLogin;
#NotBlank
private String password;
public User() {
super();
}
public User(String dob, String name, String surname, String ppsn, String address, String phone, String email, String password) {
super();
this.dob = dob;
this.name = name;
this.surname = surname;
this.ppsn = ppsn;
this.address = address;
this.phone = phone;
this.email = email;
this.password = password;
}
public Long getId() {
return id;
}
public String getDob() {
return dob;
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
public String getPpsn() {
return ppsn;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getNextApptId() {
return nextApptId;
}
public void setNextApptId(String apptId) {
this.nextApptId = apptId;
}
public String getDose1Date() {
return dose1Date;
}
public void setDose1Date(String dose1Date) {
this.dose1Date = dose1Date;
}
public String getDose2Date() {
return dose2Date;
}
public void setDose2Date(String dose2Date) {
this.dose2Date = dose2Date;
}
public String getLastLogin() {
return lastLogin;
}
public void setLastLogin(String lastLogin) {
this.lastLogin = lastLogin;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
But for some reason I can't figure out, the first four fields - i.e. Dob (date of birth), Name, Surname, and PPSN, are producing a null error when instantiating the user object on the server side, e.g.:
`Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 4 errors<EOL>
Field error in object 'user' on field 'dob': rejected value [null]; codes [NotBlank.user.dob,NotBlank.dob,NotBlank.java.lang.String,NotBlank]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.dob,dob]; arguments []; default message [dob]]; default message [must not be blank] `.
The other four fields, Address, Phone, Email, and Password appear to be working just fine.
As far as I can make out, there it isn't a typo issue (forgive me if that ends up being the case). I have intercepted the Post request using Burp to check that the contents of the fields were making it out of the form and into the request, with the right names for the fields in my User class, and indeed they are all there as intended.
I imagine this means that the issue is coming from how the back end controller code is interpreting this post request based on the model, but I have no real idea of how or where to start. Here is the current controller:
#GetMapping("/register")
public String startRegistration(Model model) {
model.addAttribute("user", new User());
return "register";
}
#PostMapping("/register_attempt")
public String registerAttempt(#Valid User newUser) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode(newUser.getPassword());
newUser.setPassword(encodedPassword);
userRepository.save(newUser);
return "registered_successfully";
}
EDIT: Further debugging & clarification with issue persisting
Removing the #Valid annotation from the Post Mapping and using old fashioned print statements shows the same results - that the first four fields are null, for no obvious reason.
#PostMapping("/register_attempt")
public String registerAttempt(#ModelAttribute("user") User newUser) {
System.out.println("Saving user ");
System.out.println("Name " + newUser.getName());
System.out.println("Last Name " + newUser.getSurname());
System.out.println("PPSN " +newUser.getPpsn());
System.out.println("DOB " +newUser.getDob());
System.out.println("email " +newUser.getEmail());
System.out.println("address " +newUser.getAddress());
System.out.println("encrypted password " +newUser.getPassword());
System.out.println("Phone num " +newUser.getPhone());
userRepository.save(newUser);
System.out.println("User saved");
return "registered_successfully";
}
Using the following dummy data:
Which sends this Post Request to the back end:
Results in these print statements:
Saving user
name null
last Name null
ppsn null
dob null
email foo#bar.com
address Here and there
password password
Phone num 987654321
And these error messages:
javax.validation.ConstraintViolationException: Validation failed for classes [app.model.User] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='must not be blank', propertyPath=surname, rootBeanClass=class app.model.User, messageTemplate='{javax.validation.constraints.NotBlank.message}'}
ConstraintViolationImpl{interpolatedMessage='must not be blank', propertyPath=dob, rootBeanClass=class app.model.User, messageTemplate='{javax.validation.constraints.NotBlank.message}'}
ConstraintViolationImpl{interpolatedMessage='must not be blank', propertyPath=name, rootBeanClass=class app.model.User, messageTemplate='{javax.validation.constraints.NotBlank.message}'}
ConstraintViolationImpl{interpolatedMessage='must not be blank', propertyPath=ppsn, rootBeanClass=class app.model.User, messageTemplate='{javax.validation.constraints.NotBlank.message}'}
]
If you have any insight into why this might be happening, I would very much appreciate it.
You have th:object="${user}" in your Thymeleaf template, so I have to assume that you #GetMapping method in your controller has added an instance of User to the Model using addAttribute.
In your #PostMapping, you should also use #ModelAttribute:
#PostMapping("/register_attempt")
public String registerAttempt(#Valid #ModelAttribute("user") User newUser) {
...
You also need to have setters for each field. I see that User has no setName(String name), no setDob(String dob), ...
Some other tips:
Do not create BCryptPasswordEncoder instances in your controller method itself. When you use Spring Boot, this should be an application wide singleton (Called a bean in Spring lingo). Add a class to your application e.g. ReservationSystemApplicationConfiguration which declares this:
#Configuration
public class ReservationSystemApplicationConfiguration {
#Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
Then in your controller, inject the password encoder:
#Controller
#RequestMapping("...")
public class MyController {
private final PasswordEncoder passwordEncoder;
public MyController(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
#PostMapping("/register_attempt")
public String registerAttempt(#Valid #ModelAttribute("user") User newUser) {
String encodedPassword = passwordEncoder.encode(newUser.getPassword());
newUser.setPassword(encodedPassword);
userRepository.save(newUser);
return "registered_successfully";
}
}
A Controller should not directly call the Repository, but use a Service in between.
It is better to use different objects for mapping the form data and for storing the data into the database. See Form Handling with Thymeleaf for more information on how to do that.

Access Multiple beans using thymeleaf and springboot MVC

Trying to access multiple objects in the POST method using SpringBoot MVC and thymeleaf.
here is the controller.
#Controller
public class PatientController {
ObjectMapper Obj = new ObjectMapper();
#GetMapping("/patient")
public static String patientForm(Model model) {
model.addAttribute("patient", new PatientDataModel());
model.addAttribute("patient1", new PatientDataModel1());
return "patient";
}
#RequestMapping(value="/patient", method=RequestMethod.POST, params="action=Send data to MongoDB cluster")
public static String patientSubmit(#ModelAttribute("patient") PatientDataModel patient, #ModelAttribute("patient1") PatientDataModel patient1, Model model, Object obj ) throws JsonProcessingException {
model.addAttribute("patient", patient);
model.addAttribute("patient1", patient1);
return "result";
}
and here are the views:
patient.html
<form action="#" th:action="#{/patient}" th:object="${patient}" method="post">
<div th:object="${patient1}" >
<p>Patient Id: <input type="text" th:value="${patient.id}" /></p>
<p>Patient Name: <input type="text" th:value="${patient.name}" /></p>
<p>Message: <input type="text" th:value="${patient.content}" /></p>
<p>address: <input type="text" th:value="${patient1.address}" /></p>
</div>
<p><input type="submit" name="action" value="Send data to MongoDB cluster" />
<input type="reset" value="Reset" /></p>
</form>
</div>
and result.html
<div class="starter-template">
<h1>Result</h1>
<p th:text="'id: ' + ${patient.id}" />
<p th:text="'Name: ' + ${patient.name}" />
<p th:text="'content: ' + ${patient.content}" />
<p th:text="'address: ' + ${patient1.address}" />
Submit another message
</div>
and the bean classes are : PatientDataModel.java
public class PatientDataModel {
private long id;
private String content;
private String name;
public PatientDataModel()
{
}
public PatientDataModel(long id, String content, String name)
{
this.id = id;
this.content = content;
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
#Override
public String toString()
{
return "Patient [id=" + id + ", firstName=" + name + ", " +
"content=" + content + "]";
}
}
another bean :
public class PatientDataModel1 {
private String address;
#Override
public String toString() {
return "Patient1 [address=" + address + "]";
}
public PatientDataModel1()
{
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
now , the issue is , I need both the beans to be accessible in the GET and POST method.
when I am running the code , it is executing but the beans does not have values , all are null . pls suggest
It will be easiest to have 1 object to find to the form. Create a new class PatientFormData for example that contains all the fields from the 2 objects and convert from/to the objects you have in the get and post methods in your controller.
For example:
public class PatientFormData {
private long id;
private String content;
private String name;
private String address;
public static PatientFormData from(PatientDataModel model,
PatientDataModel1 model1) {
id = model.getId();
content = model.getContent();
name = model.getName();
address = model.getAddress();
}
public PatientDataModel createPatientDataModel() {
PatientDataModel result = new PatientDataModel();
result.setId(id);
result.setContent(content);
result.setName(name);
return result;
}
// getters and setters here
}
Use this in the controller:
#Controller
public class PatientController {
ObjectMapper Obj = new ObjectMapper();
#GetMapping("/patient")
public static String patientForm(Model model) {
PatientFormData formData = PatientFormData.from(new PatientDataModel(), new PatientDataModel1());
model.addAttribute("patientFormData", formData);
return "patient";
}
#RequestMapping(value="/patient", method=RequestMethod.POST, params="action=Send data to MongoDB cluster")
public static String patientSubmit(#ModelAttribute("patientFormData") PatientFormData formData, Model model, Object obj ) throws JsonProcessingException {
PatientDataModel model = formData.createPatientDataModel();
PatientDataModel1 model1 = formData.createPatientDataModel1();
// Do more processing with objects
return "result";
}
Also be sure to correctly use the field binding using *{..}:
<form action="#" th:action="#{/patient}" th:object="${patientFormData}" method="post">
<p>Patient Id: <input type="text" th:value="*{id}" /></p>
<p>Patient Name: <input type="text" th:value="*{name}" /></p>
<p>Message: <input type="text" th:value="*{content}" /></p>
<p>address: <input type="text" th:value="*{address}" /></p>
</div>
<p><input type="submit" name="action" value="Send data to MongoDB cluster" />
<input type="reset" value="Reset" /></p>
</form>
</div>

[Failed to convert property value of type 'java.lang.String[]' to required type 'java.util.List' for property

I am working with Thymeleaf and trying to do some object binding, but I do not know how to do it if I have an object with a list. Let me explain:
My model:
#Entity
public class Project {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#NotNull
private String name;
#NotNull
#Lob
private String description;
#NotNull
private Date startDate;
private String status;
#ManyToMany
private List<Role> rolesNeeded;
#ManyToMany
private List<Collaborator> collaborators;
public Project() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public List<Role> getRolesNeeded() {
return rolesNeeded;
}
public void setRolesNeeded(List<Role> rolesNeeded) {
this.rolesNeeded = rolesNeeded;
}
public List<Collaborator> getCollaborators() {
return collaborators;
}
public void setCollaborators(List<Collaborator> collaborators) {
this.collaborators = collaborators;
}
}
My html form:
<form method="post" action="addproject" th:object="${project}">
<div>
<label for="project_name"> Project Name:</label>
<input th:field="*{name}" type="text" name="project_name"/>
</div>
<div>
<label for="project_description">Project Description:</label>
<textarea th:field="*{description}" rows="4" name="project_description"></textarea>
</div>
<div>
<label for="project_status">Project Status:</label>
<div class="custom-select">
<span class="dropdown-arrow"></span>
<select th:field="*{status}" name="project_status">
<option value="active">Active</option>
<option value="archived">Archived</option>
<option value="not_started">Not Started</option>
</select>
</div>
</div>
<div>
<label for="project_roles">Project Roles:</label>
<ul class="checkbox-list">
<li th:each="role : ${roles}">
<input th:field="*{rolesNeeded}" type="checkbox" name="project_roles" th:value="${role}"/>
<span class="primary" th:text="${role.name}"> Developer</span>
</li>
</ul>
</div>
<div class="actions">
<input type="submit" value="Save" class="button"/>
Cancel
</div>
</form>
And I am getting the error:
ERROR!!!!: Field error in object 'project' on field 'rolesNeeded':
rejected value
[com.imprender.instateam.model.Role#145d6cd4,com.imprender.instateam.model.Role#73020d6f];
codes
[typeMismatch.project.rolesNeeded,typeMismatch.rolesNeeded,typeMismatch.java.util.List,typeMismatch];
arguments
[org.springframework.context.support.DefaultMessageSourceResolvable:
codes [project.rolesNeeded,rolesNeeded]; arguments []; default message
[rolesNeeded]]; default message [Failed to convert property value of
type 'java.lang.String[]' to required type 'java.util.List' for
property 'rolesNeeded'; nested exception is
java.lang.IllegalStateException: Cannot convert value of type
'java.lang.String' to required type
'com.imprender.instateam.model.Role' for property 'rolesNeeded[0]': no
matching editors or conversion strategy found]
Basically, as far as I understood, the checkbox input returns a String[], but my object needs a list, so the binding cannot be perfomed.
How could I bind the array in the list? (do you have an example?)
Thank you.
If Your Role bean has active boolean property, You could do something like this (simplified):
<ul class="checkbox-list">
<li th:each="role,stat : ${project.rolesNeeded}">
<input th:field="*{rolesNeeded[__${stat.index}__].active}" type="checkbox"/>
<input th:field="*{rolesNeeded[__${stat.index}__].name}" type="hidden"/>
<span class="primary" th:text="${role.name}">Developer</span>
</li>
</ul>
If it does not, you could store the rolesNeeded in the hidden fields and populate them with javascript.

Form validation error messages not appearing as expected

<td th:if="${#fields.hasErrors('description')}" th:errors="*{description}" class="red">You must provide a reason for your request.</td>
<td th:if="${#fields.hasErrors('selectedDate')}" th:errors="*{selectedDate}" class="red">You must select a date.</td>
Why are these td being populated by the following messages instead of the messages I have provided above? They also don't take on the css class I provided.
may not be empty may not be empty
Request Entity:
public class RequestModel {
private Long requestId;
#NotNull
#NotBlank
private String selectedDate;
private RequestStatus requestStatus;
#NotNull
#NotBlank
private String description;
private Boolean hasForced;
public String getSelectedDate() {
return selectedDate;
}
public void setSelectedDate(String selectedDate) {
this.selectedDate = selectedDate;
}
public Long getRequestId() {
return requestId;
}
public void setRequestId(Long requestId) {
this.requestId = requestId;
}
public RequestStatus getRequestStatus() {
return requestStatus;
}
public void setRequestStatus(RequestStatus requestStatus) {
this.requestStatus = requestStatus;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Boolean getHasForced() {
return hasForced;
}
public void setHasForced(Boolean hasForced) {
this.hasForced = hasForced;
}
}
Controller:
#RequestMapping(value = "/save", method = RequestMethod.POST)
String saveRequest(Principal principal, #Valid #ModelAttribute(value = "requestModel") RequestModel requestModel, BindingResult bindingResult, RedirectAttributes redirectAttributes) {
if (bindingResult.hasErrors()) {
// log.info("There are binding errors.");
return "send";
}
...
}
The full HTML form:
<form role="form" th:action="#{/request/save}" th:object="${requestModel}" method="post">
<input type="checkbox" th:field="*{hasForced}" th:checked="${false}" style="display: none;"/>
<p><input id="description" class="descriptionField" type="text" th:field="*{description}"
placeholder="Please provide a reason for your request"
style="width: 500px; border-radius: 4px; padding: 11px 11px 11px 11px;"/></p>
<input id="embeddedDateField" class="dateField" placeholder="YYYY-MM-DD" type="text" th:field="*{selectedDate}" readonly
style="border-radius: 4px; background: #eefdff; text-align: center;"/><br>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div style="margin: 5px; width: 200px;"><input type="submit" value="Submit Request"
style="display: block;"></div>
<td th:if="${#fields.hasErrors('description')}" th:errors="*{description}" class="red">You must provide a reason for your request.</td>
<td th:if="${#fields.hasErrors('selectedDate')}" th:errors="*{selectedDate}" class="ed">You must select a date.</td>
</form>
What's going on here?
These messages are coming from validation annotation default values. To set your own you need to provide them like below or you can change from properties file using MessageSource.
#NotNull(message="You must select a date.")
#NotBlank(message="You must select a date.")
private String selectedDate;

How to pass html input values into database from form (Springboot)

I have a local Oracle database with which I've established a solid connection. Now I just want to POST data from an HTML input form using a Controller to handle said data.
My form looks like this:
<form action="/request/save" method="post">
<input type="text" id="dateInput" name="requestDate" value="1" style="display: none;"/>
<input type="text" name="description" value="This is a test request." style="display: none;"/>
<input type="text" name="status" value="false" style="display: none;"/>
<div style="width: 200px;"><input type="submit" value="Submit Request" style="display: block;"></div>
</form>
Controller:
#RequestMapping(value = "/save", method = RequestMethod.POST)
String saveRequest(Principal principal, #ModelAttribute Request request, Model model) {
// Set UserId to Request Field USER_ID
Users user = usersRepository.findOneByInitialName(principal.getName());
Request requestObj = new Request(user, new Date());
requestObj.setId(user.getId());
// Set Additional Request Fields
requestObj.setDescription("Test");
requestObj.setStatus(false);
requestObj.setRequestDate(new Date());
// Save Request Object
requestRepository.save(requestObj);
return "requests";
}
Entity (for completion):
#Entity
public class Request {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name="request_id")
private Long id;
private Date requestDate;
private String description;
private Boolean status;
#ManyToOne(fetch=FetchType.LAZY)
#JoinColumn(name="user_id", nullable = false)
private Users users;
public Request() {}
public Request(Users user, Date requestDate) {
this.setUsers(user);
this.setRequestDate(requestDate);
}
#Override
public String toString() {
return String.format(
"Request[id=%d, inital='%s', requestDate='%s']",
getId()
, getUsers().getInitialName()
, getRequestDate());
}
public Date getRequestDate() {
return requestDate;
}
public void setRequestDate(Date requestDate) {
this.requestDate = requestDate;
}
public Boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
this.status = status;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Users getUsers() {
return users;
}
public void setUsers(Users users) {
this.users = users;
}
}
How can I send the data from the form to my database?
Error:
Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.
You might have configured csrf filter in your web.xml, so you need to pass "X-CSRF-TOKEN" in your request header.

Categories

Resources