request mapping issue – spring mvc

I am facing an issue with the request mapping in as:
There are two url by which I am able to see the response of uploadPage.jsp

  1. http://localhost:8080/dms/files/?module=abc
  2. http://localhost:8080/dms/files?module=abc

The form in uploadPage.jsp is successfully submitted for the url 1 and the url in browser displayed as http://localhost:8080/dms/files/upload.
But for the url 2 there is an error with the browser url as http://localhost:8080/dms/upload.

What is the problem with this url mapping?


package dms.spring.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import dms.pojo.CrmDms;

@RequestMapping(value = "/files")
public class FileUploadController2
    @RequestMapping(method = RequestMethod.GET)
    public String index( HttpServletRequest webRequest, ModelMap map )
        String module = webRequest.getParameter( "module" );
        CrmDms crmDms = new CrmDms();
        crmDms.setModule( module );
        map.put( CrmDms.class.getSimpleName(), crmDms );
        return "uploadPage";

    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public String uploadFile( @ModelAttribute(value = "CrmDms") CrmDms crmDms,
                              @RequestParam(value = "document") MultipartFile file,
                              ModelMap modelMap )
        System.out.println( crmDms.getModule() );
        return "successPage";

JSP (uploadPage.jsp):

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib uri="" prefix="sf"%>
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <div id="main-wrapper">
    <sf:form action="upload" method="post" commandName="CrmDms">
      <sf:input path="module" />
      <input type="submit" value="Submit">

Source: jsp

Leave a Reply