Note that there are some explanatory texts on larger screens.

plurals
  1. PORequestMapping in spring mvc
    primarykey
    data
    text
    <p>I am trying to understand requestmapping in spring mvc, I have an application, actually I am just getting started with spring mvc.</p> <p>I have these two urls</p> <p>The first one with a forward slash at the end seems to be working fine. <code>http://localhost:8080/contactmanager/index/</code></p> <p>The second one without a forward slash at the end does not work</p> <pre><code>http://localhost:8080/contactmanager/index </code></pre> <p>This second one gives me the 'HTTP Status 404 -' error, how can I force the application to be appending a forwards slash at the end of the url?</p> <p>The method in the controller looks like this</p> <pre><code>@RequestMapping("/index") public String listContacts(Map&lt;String, Object&gt; map) { map.put("contact", new Contact()); map.put("contactList", contactService.listContact()); //org.springframework.web.context.ContextLoaderListener //org.springframework.web.context.ContextLoaderListener //org.springframework.web.servlet.DispatcherServlet //org.springframework.web.servlet.DispatcherServlet return "contact"; } </code></pre> <p>and my web.xml looks like this</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;contactmanager&lt;/servlet-name&gt; &lt;servlet-class&gt; org.springframework.web.servlet.DispatcherServlet &lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/contactmanager-servlet.xml&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;contactmanager&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload