La Carbonell
La Carbonell

Reputation: 2056

HTTP 404 Not Found Error in Spring 3.2.8 application

I have an application based in the Spring Web model-view-controller (MVC) framework I have this controller

@Controller
public class ApplicantApplicationsListController extends ApplicantController {


    /**
     * @throws Exception    
     *                                 
     */
    @RequestMapping(value = {       "/medrano/applicant/home",                                   
                                    "/medrano/applicant/home/"}, method = {RequestMethod.GET})
    public String viewProductApplications   (@ModelAttribute("applicationApplicationsListForm") final ApplicationApplicationsListForm applicationApplicationsListForm,
                                             HttpServletRequest request,
                                             Model model ) throws Exception {

        return "applicantApplicationsView";

    }

But I got a 404 in the browser when I put

http://127.0.0.1:7001/cage/medrano/applicant/home

Upvotes: 1

Views: 279

Answers (2)

La Carbonell
La Carbonell

Reputation: 2056

I forgot to Configure the Spring DispatcherServlet in the file web.xml with:

    ...             
    <servlet-mapping>
         <url-pattern>//medrano/applicant/home</url-pattern>  
         <url-pattern>//medrano/applicant/home/</url-pattern>           
    </servlet-mapping>
    ...

Upvotes: 0

cнŝdk
cнŝdk

Reputation: 32145

You have a mapping problem with your request mapping:

The annotation @RequestMapping value property expects an array of Strings, in your case:

value = {"/medrano/applicant/home",                                   
             "/medrano/applicant/home/",}

Is not a valid String[], you have an additional , at the end, just remove it.

You can check the Spring MVC @RequestMapping Annotation Example with Controller, Methods, Headers, Params, @RequestParam, @PathVariable tutorial for further exmaples on how to use it.

Edit:

  • There's no need to use the brackets with a single value for both
    value and method properties.
  • And why would you use the same value "/medrano/applicant/home" twice in your RequestMapping.

It could simply be like this:

@RequestMapping(value = "/medrano/applicant/home", 
                 method = RequestMethod.GET)

Upvotes: 2

Related Questions