0

I am using Spring MVC framework for writing a web application. The first step is to modify the web.xml to make entry for the dispatcher servlet.

The snippet of the web.xml which has this change:

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

<servlet-mapping>
      <servlet-name>MediumScaleProject</servlet-name>
      <url-pattern>/*</url-pattern>
</servlet-mapping>

I have following questions:

1) Does this mean anything with respect to context root has to go through this servlet mapping? (assume context root for this web application is /contextroot)

2) I want to capture user details in userDetails.html; with the above arrangement it is not working, that is if I access like this: /contextroot/userDetails.html; it is giving HTTP 404 error. What is the best strategy for handling these kind of scenarios?

CuriousMind
  • 8,301
  • 22
  • 65
  • 134
  • Could you post some code snippet of controller please? – Blank Jun 07 '16 at 08:29
  • No, I have not written any controller, this is just an .html page, which a user would request initially. Does this simple page access too needs to have all the request handling logic? – CuriousMind Jun 07 '16 at 08:31
  • I think yes, or you can set this page to tag `welcome-file-list`, or you can configure another servlet to map this url. – Blank Jun 07 '16 at 08:35
  • 1
    I once wrote a [Q+A](http://stackoverflow.com/questions/26325524) on the possibility of serving static files in a Spring-MVC application. Hope it helps... – Serge Ballesta Jun 07 '16 at 12:05

1 Answers1

0

If you want to make a project with the use of Spring MVC framework, you will need the Model, View and Controller.

  1. yes everything will pass through
  2. you better start to implement the MVC-idea
AlieneilA
  • 278
  • 1
  • 3
  • 15