Я новичок в пружине MVC. Получение нулевых значений в качестве выходных данных в форме пружины MVC с использованием Maven java. как получить значения из файлов на мой jsp. Пожалуйста, помогите выбраться из этого.
JSP создан как показано ниже
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//w3c//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="../store" method="post">
Eno:<input type="text name="eno"/>
Name:<input type="text name="name"/>
Address:<input type="text name="address"/>
ContactNumber:<input type="text name="contact"/>
EmailId:<input type="text name="email"/>
Salary:<input type="text name="salary"/>
<input type="submit"
value="store" />
</form>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</body>
</html>
Это мой файл контроллера, где выполняется сопоставление запроса.
package webapp1;
import javax.servlet.ServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(path="/store")
public class EmployeeController {
@RequestMapping(method=RequestMethod.POST)
public String saveEmployee(Employee employee,Model model) {
System.out.println("eno:"+ employee.getEno()+"\n");
System.out.println("name:"+ employee.getName()+"\n");
System.out.println("address:"+ employee.getAddress()+"\n");
System.out.println("contact:"+ employee.getContact()+"\n");
System.out.println("email:"+ employee.getEmail()+"\n");
System.out.println("salary:"+ employee.getSalary()+"\n");
model.addAttribute("employee",employee);
return "display";
}
}
Я сделал getter и setter в отдельном файле, где getter и setter сделаны
package webapp1;
public class Employee {
private Integer eno;
private String name;
private String address;
private Double contact;
private String email;
private Double salary;
public Employee() {
}
public Integer getEno() {
return eno;
}
public void setEno(Integer eno) {
this.eno = eno;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Double getContact() {
return contact;
}
public void setContact(Double contact) {
this.contact = contact;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Double getSalary() {
return salary;
}
public void setSalary(Double salary) {
this.salary = salary;
}
public Employee(Integer eno, String name, String address, Double contact, String email, Double salary) {
super();
this.eno = eno;
this.name = name;
this.address = address;
this.contact = contact;
this.email = email;
this.salary = salary;
}
}