Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring Controller

 
Ranch Hand
Posts: 546
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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;
}

}
 
Sheriff
Posts: 67694
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please continue in your original post on this issue.
 
    Bookmark Topic Watch Topic
  • New Topic