Hello,
I am very new to Spring and have been struggling with this for a few hours now! I am just completely blank. Please help.
I have a simple
JSP page which gets a name from the user. I just want to print the name in the controller as a first step. I don't know how to access the "name".
view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
<html>
<body>
<form action="search">
Enter an employee name<input type="text" name="name" /><br/>
<input type="submit" value="submit" />
</form>
</body>
</html>
Here is my controller:
view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
@Override
protected ModelAndView onSubmit(Object command)throws Exception{
Employee emp =(Employee)command;
String name = emp.getName();
System.out.println(name);
}
Here is my Employee class:
view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
package com.cts.other;
public class Employee {
String name;
public Employee() {
}
Employee(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}