title: Simple search in Spring MVC
body: <p>I'm new to Spring MVC, and I'm trying to do a simple search.
  Here's my Controller and View. How do I make the search to actually work?
   The findTeamByName is already implemented from a interface and the Teams are already populated in memory.
  Thank you in advance guys!</p>
  
  <pre><code>@Controller
  public class SearchController {
  
    @Autowired    
    SuperPlayerService sp;
  
    @RequestMapping(value="/search")
      public ModelAndView Search(@RequestParam(value = "searchTerm", required = false) 
      String pSearchTerm, HttpServletRequest request, HttpServletResponse response) {
          ModelAndView mav = new ModelAndView("search");
  
         mav.addObject("searchTerm", pSearchTerm);
         mav.addObject("searchResult", sp.findTeamByName(pSearchTerm));      
  
       return mav;
     }
  }
  </code></pre>
  
  <p>JSP:</p>
  
  <pre><code>&lt;%@ page contentType="text/html" pageEncoding="UTF-8" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ taglib prefix="t" tagdir="/WEB-INF/tags" %&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %&gt;
  
  
  &lt;t:MasterTag&gt;
  &lt;jsp:attribute name="pageTitle"&gt;&lt;c:out value="Search"/&gt;&lt;/jsp:attribute&gt;
  &lt;jsp:attribute name="currentMenuName"&gt;&lt;c:out value="Search"/&gt;&lt;/jsp:attribute&gt;
  &lt;jsp:body&gt;
  
  
  
  
  
  &lt;div class="row"&gt;
       &lt;div class="small-3 columns"&gt;
          &lt;input type="text" id="txt" name="searchString"&gt;
        &lt;/div&gt;
  
         &lt;div class="small-5 columns end"&gt;
           &lt;button id="button-id" type="submit"&gt;Search Teams&lt;/button&gt;
         &lt;/div&gt;
  
     &lt;/div&gt;
  
   &lt;div class="row"&gt;
        &lt;div&gt;
           ${searchTerm}
       &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>