0

When I am starting my web application using Spring MVC.

It should start with below URL by default: http://localhost:8080/myapp/index.jsp

but not with http://localhost:8080/myapp/

Is it possible to redirect to index.jsp with using annotation (other than writing it down on web.xml as Welcomelist)

Thanks in advance.

Naresh Raj
  • 297
  • 1
  • 6
  • 18
  • A web server does not have a current URL. You need to learn more of the basics about the web. Giving that information would amount to a tutorial, which would be too much. – Raedwald Mar 05 '16 at 13:08
  • I will take your word and will correct my basics. But can you please give me an idea as where should configure this to start my application with http://localhost:8080/myapp/index.jsp instead of http://localhost:8080/myapp/ – Naresh Raj Mar 05 '16 at 13:15
  • How do you going to `Start` web application? It will be started from URL entered by user. You can't control this moment. Possible, you would like to go to `localhost:8080/myapp/index.jsp` when user types ` `localhost:8080/myapp`? – Ken Bekov Mar 05 '16 at 15:31
  • By the way, usually in Spring `.jsp` extension is not needed, because by default it is defined as suffix in `InternalResourceViewResolver` bean. – Ken Bekov Mar 05 '16 at 15:34

1 Answers1

1

Assuming that index.jsp is your first page, configure web.xml to open it first.

<welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

EDIT: You can define mappings in @WebConfig, and get your project started, but you will still need a web.xml welcome-file-list. See @WebServlet annotation web.xml welcome-file for some discussion.

Community
  • 1
  • 1
K.Nicholas
  • 10,956
  • 4
  • 46
  • 66