title: Java Spring Friendly Url mapping issues
body: <p>I've been trying to implement friendly url mapping in my first Java spring site. I've been following this tutorial. <a href="http://outbottle.com/spring-3-web-mvc-friendly-url-using-requestmapping-variable-uri/" rel="nofollow">http://outbottle.com/spring-3-web-mvc-friendly-url-using-requestmapping-variable-uri/</a></p>
  
  <p>My current mapping works well with id's as parameters. localhost:8080/user?id=1312321321</p>
  
  <pre><code>/*
   * User
  */
  @RequestMapping(method=RequestMethod.GET, value={"/user","/user/{id}"})
  public ModelAndView profileDisplay(
          HttpServletRequest request,
          HttpServletResponse response,
          @RequestParam(value="id", required=false) String id
  ) throws UnknownHostException, MongoException {
      ServiceSerlvet.appendSesssion(request);
      //get search ALL users
      BasicDBObject searchQuery = new BasicDBObject();
          searchQuery.put("_id", new ObjectId(id));
      List&lt;DBObject&gt; searchResponse = PersonController.searchUsers(searchQuery);
  
      //System.out.println("response from search user method: "+searchResponse);
  
      return new ModelAndView("user", "people", searchResponse);
  }
  </code></pre>
  
  <p>My web xml currently looks like this... its working but is it correct to write out various url mapping like this? I take it the * is a wild card to allow say /user/22222?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;Spring3MVC&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
                    org.springframework.web.servlet.DispatcherServlet
                &lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  
  
      &lt;url-pattern&gt;/gallery/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/galleryupload/*&lt;/url-pattern&gt;
  
      &lt;url-pattern&gt;/delete/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/edit/*&lt;/url-pattern&gt;
  
      &lt;url-pattern&gt;/search/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/members/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/profile/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/messages/*&lt;/url-pattern&gt;
  
      &lt;url-pattern&gt;/index/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/login/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/logout/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/register/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/user/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/jsoninterests/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/jsonlocations/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/jsonmembers/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/jsonuniqueuser/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>When I try and adapt my code to take just a name like this localhost:8080/user/john</p>
  
  <p>it breaks - but I am unsure how to set the mapping in the web.xml, do I set the mapping like this in web.xml?</p>
  
  <pre><code>@RequestMapping(value="/user/{id}", method= RequestMethod.GET)
          public ModelAndView profileDisplay(
                  @PathVariable(value="id") String id,
                  HttpServletRequest request,
                  HttpServletResponse response
          ) throws UnknownHostException, MongoException {
  
      ServiceSerlvet.appendSesssion(request);
              //get search ALL users
              BasicDBObject searchQuery = new BasicDBObject();
                  searchQuery.put("_id", new ObjectId(id));
              List&lt;DBObject&gt; searchResponse = PersonController.searchUsers(searchQuery);
  
              //System.out.println("response from search user method: "+searchResponse);
  
              return new ModelAndView("user", "people", searchResponse);
          }
  </code></pre>