0

I have this class in my Spring Web model-view-controller (MVC) framework. The version of the Spring Web model-view-controller (MVC) framework is 3.2.8.

I have this web.xml file.

...
<servlet-mapping>
                <servlet-name>ecolabelWeb</servlet-name>
                <url-pattern>*.do</url-pattern>

                <url-pattern>/newdesign/manage/manageapplications</url-pattern>    
                <url-pattern>/newdesign/manage/manageapplications/</url-pattern>
                <url-pattern>/newdesign/manage/manageapplications/*</url-pattern>

                <url-pattern>/newdesign/manage/home</url-pattern>    
                <url-pattern>/newdesign/manage/home/</url-pattern>
                <url-pattern>/newdesign/manage/home/*</url-pattern>

                <!-- Explicitly mention /welcome.do for usage as welcome page -->
                <url-pattern>/welcome/welcome.do</url-pattern>
        </servlet-mapping>
...

and this controller:

/** 
     * 
     */
    @RequestMapping(value = { "/newdesign/manage/home", 
                              "/newdesign/manage/home/",
                              "/newdesign/manage/manageapplications", 
                              "/newdesign/manage/manageapplications/"}, method = {RequestMethod.GET})
    public String manageApplications    (@ModelAttribute("aplicationListForm") final AplicationListForm aplicationListForm,
                                         HttpServletRequest request,
                                         Model model ) throws ExecutionException {


        User sessionUser = (User)request.getSession().getAttribute(Const.SESSION_USER);
        ..
}

this URL works properly

/newdesign/manage/manageapplications

but with this one newdesign/manage/home

I got this error

WARNING: No mapping found for HTTP request with URI [/devices/newdesign/manage/home]

I am really getting crazy !

I also tried to put it in another method with the same result

@RequestMapping(value = { "/newdesign/manage/home", 
                              "/newdesign/manage/home/"}, method = {RequestMethod.GET})
    public String cbHome    (Model model ) throws ExecutionException {
    ..
}

This URL is working http://127.0.0.1:7001/devices/newdesign/manage/manageapplications not this one (?!) http://127.0.0.1:7001/devices/newdesign/manage/home

Amadeu Cabanilles
  • 913
  • 3
  • 19
  • 47
  • devices is you application context ? – vincent Dec 09 '16 at 13:16
  • yes: http://127.0.0.1:7001/devices/newdesign/manage/home – Amadeu Cabanilles Dec 09 '16 at 13:21
  • You shouldn't map your servlet to the urls of the controller. By default the mappings are done inside the mapping of the dispatcher servlet. Next to that `/newdesign/manage/home` already implies `/newdesign/manage/home/`. You should map your servlet to `/` or `/*` to make it work or configure your request mappings to use the complete url instead of the last part. – M. Deinum Dec 09 '16 at 13:30
  • What do you mean ? remove it from web.xml ? – Amadeu Cabanilles Dec 09 '16 at 13:31
  • @AmadeuCabanilles, Are you sure that the form that request this */newdesign/manage/home* gets embedded with the extension ? Like `
    `
    – Fevly Pallar Dec 09 '16 at 14:19
  • It is a GET , I put it on the browser – Amadeu Cabanilles Dec 09 '16 at 14:22
  • I mean that maybe you missed the *.do*. Btw, According to the method this *AplicationListForm* will be bound to form's properties/values , thus if you directly hit it on browser nothing gets bound. – Fevly Pallar Dec 09 '16 at 14:25
  • cant see anywhere any controller mapped to `/devices/*` so i suppose , Spring is doing its job properly by throwing the exception. Also , as mentioned by @M.Deinum , you have placed the URL mappings in both the controller and the web.xml , so if someone f.e. wanted the `/newdesign/manage/home` , he should hit `localhost:8080/newdesign/manage/home/newdesign/manage/home`. Check the posted answer , and read carefully the examples you ve been using – AntJavaDev Dec 09 '16 at 14:31
  • also regarding your post , *this URL works properly `/newdesign/manage/manageapplications`* , could you post , the whole URL you are requesting , and it works properly....? – AntJavaDev Dec 09 '16 at 14:38

1 Answers1

0

Your configuration doesn't work because in your web.xml you have limited your application to work only with these url:

<url-pattern>/newdesign/manage/manageapplications</url-pattern>    
<url-pattern>/newdesign/manage/manageapplications/</url-pattern>
<url-pattern>/newdesign/manage/manageapplications/*</url-pattern>

This is a tipical web.xml:

<servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

With this configuration you are telling Spring to use the dispatcher servlet mechanism to handle the incoming requests and the view rendering. This way he can handle all the url you are defining in controllers, like /newdesign/manage/home.

You need to create the dispatcher-servlet.xml file where you will configure the dispatcher.

See this link for more detailed informations: http://www.mkyong.com/spring-mvc/spring-mvc-hello-world-example/

Community
  • 1
  • 1
amicoderozer
  • 2,046
  • 6
  • 28
  • 44