Note that there are some explanatory texts on larger screens.

plurals
  1. PO@RequestMapping in spring not working
    primarykey
    data
    text
    <p>I am new in Spring MVC. I created one controller <code>newController.java</code> in <code>springproject</code>. My code is below:</p> <pre><code>@RequestMapping(value = "/Receiver", method = RequestMethod.GET) public void recvHttpGet(Model model) { System.out.println("here get"); newmethod(); } @RequestMapping(value = "/Receiver", method = RequestMethod.POST) public void recvHttpPost(Model model) { System.out.println("here post"); newmethod(); } @RequestMapping(value = "/", method = RequestMethod.GET) public String show(Model model) { return "index"; } </code></pre> <p>web.xml</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;ClassPath:/spring/applicationContext.xml, ClassPath:/spring/hibernateContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;servlet&gt; &lt;servlet-name&gt;appServlet&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;&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;appServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p></p> <p>whenever I try to run it then <code>index.jsp</code> page is shown but whenever I try to call <code>/Receiver</code> url it shows a 404 error. Please help me. Also when I changed in <code>recvHttpGet</code> method <code>return "index"</code> it also shows a 404 error. Also nothing is wrote to the console.</p> <p>I wants to just check which method calls so wants to write in console window but it does not show anything.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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