Welcome file not working with html file in spring
Try adding <mvc:default-servlet-handler/>
in your dispatcher-servlet.xml.
See here for details.
You have mapped all your incoming requests to the dispatcher
here,
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
So all your URL
requests for the application goes inside the dispatcher as '/' maps all incoming requests . check for the stacktraces in your application server log
update:
You get the below warning because there are no handler for the '/' pattern,
WARNING: No mapping found for HTTP request with URI [/AccelFlow/] in DispatcherServlet with name 'dispatcher'
You can do either of below options ,
- Map a url with '/' to the controller
- Add a specific URL pattern to the spring dispatcher such as
.htm or .do
as you wish
Modify your web.xml,
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
And in your controller,
@RequestMapping(value = "/test.htm", method = RequestMethod.GET)
public @ResponseBody Response display() throws Exception {
accelFlowFacade.disaply();
Response res = new Response();
return res;
}
At the startup by default all incoming requests are mapping to '/' pattern as you write in the web.xml:
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
update:
Try to map a Controller method for the default view:
@RequestMapping(value = "/", method = GET) public String welcome() { return "index"; }
Add viewresolver to dispather-servlet.xml:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/" p:suffix=".jsp" />
Remove welcome file from the web.xml as automatically spring will search for index page by default:
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list>