Search code examples
spring-mvcjdeveloper

Spring web application without redirection


I am trying to create a spring web application. The application should directly go to a controller and should not have any welcome file. What i am trying is

At the top of this controller I have the annotations

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

and my welcome file list has root context

<welcome-file-list>  
        <welcome-file>/</welcome-file>
    </welcome-file-list>

So my application should run as : localhost:7101/samplespring/

However , the problem is when I try to run the application in jdeveloper , I need to set a default target , which I obviously cannot here.

Hoow to proceed.

Thanks n Regards, Rachit


Solution

  • I'd remove the <welcome-file-list> entry and ensure your servlet-mapping in web.xml looks something like (note <url-pattern>):

    <servlet>
        <servlet-name>mainDispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>mainDispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>