I can't recall what I have changed on my code but whenever I click on any links on my web it gives me this :
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/favicon.ico] in DispatcherServlet with name 'mvc-dispatcher'
A portion of my web.xml
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
some configuration of my mvc-dispatcher-servlet.xml
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<mvc:resources mapping="/resources/**" location="resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
<beans:property name="order" value="1" />
</beans:bean>
<!-- testing for pdf export -->
<beans:bean class="org.springframework.web.servlet.view.XmlViewResolver">
<beans:property name="location" value="/WEB-INF/spring-pdf-views.xml" />
<beans:property name="order" value="0" />
</beans:bean>
Other than that everything works fine, means any page is loaded correctly without any error. May I know what might cause this ? And who is using that .ico image ?
Most web browsers attempt to fetch a site's favicon at the root of the context with a request for the /favicon.ico resource automatically. In your case is not handled by any configured Spring mapping.
If you have a favicon at /favicon.ico or in another location you could configure a mapping in Spring to resolve the request to a valid resource:
<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
The favicon.ico : icon in the browser tab
Since Spring Security are using
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Did you exclude the favicon.ico from filtering by Spring Security?
<http pattern="/favicon.ico" security="none" />
Try to locate favicon.ico in your html page as below:
<html>
<head>
<link href="[YOUR_FAVICON_PATH]/favicon.ico" rel="icon" type="image/x-icon" />
</head>
</html>
Related
Here is my setup / context. I have a JAR project that is using spring-boot 1.1.4 which uses Java configuration to load a properties file:
#Configuration
#ComponentScan
#EnableAutoConfiguration
#PropertySource(name="appProps", value="classpath*:application-${spring.profiles.active}.properties")
public class DataJpaApplication {
#Autowired Environment env;
#Bean
//note, this PSPSHC is ours derived from the Spring one with specialized code.
public static org.springframework.context.support.PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceHolderConfigurer encryptionPropertySourcesPlaceHolderConfigurer = new PropertySourcesPlaceHolderConfigurer();
encryptionPropertySourcesPlaceHolderConfigurer
.setIgnoreUnresolvablePlaceholders(true);
return encryptionPropertySourcesPlaceHolderConfigurer;
}
}
This jar works fine with unit tests standalone. I then try to incorporate it into a web app (spring mvc web app not using spring-boot) making it a maven dependency and adding it to the context like this:
<beans:bean id="jpaConfigBean"
class="com.somepackage.DataJpaApplication" />
I have a web app unit test that attempt to load the web app's application context and that works fine (including loading the context and property file from the jar). However, when I deploy this web app to a container (tcServer), it fails with the following:
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/application-local.properties]
edit
A clarification about the error above. The web app is loading its context and importing the jar file's context. It is this jar project that is loading the application-local.properties via #PropertySource. So, could this be around parent/child context interactions?
NOTE: No where does the code prepend a slash.
Here is how I am bootstrapping the spring config in the web app:
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:**/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
I have checked the following types of things:
Confirmed the maven generated manifest has a classpath entry for the jar file in the war file.
Changing the web.xml to use /WEB-INF/servlet-context.xml (standard path) instead
Deploy this web app in JBoss instead of tc
move the application-*.property file to another folder and refer to that folder
copy the *.property file to the web app project
confirmed the WTP deployment assembly in fact references maven
opened up the generated war file and confirmed the jar file has the file in the expected location.
and several other things with no success.
I don't see the issue. Please help figure out where the bug/misconfiguration is. Also, let me know if there is further configuration or files you need to see to help debug this issue.
Thanks in advance,
Scott
edit
complete web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- commented out for debugging...trying to reduce the complexity to get to root cause
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:**/*Context.xml,
classpath*:**/*-context.xml
</param-value>
</context-param> -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:**/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>springOpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springOpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/views/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/views/500.jsp</location>
</error-page>
<error-page>
<location>/WEB-INF/views/500.jsp</location>
</error-page>
</web-app>
complete (obfuscated) servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<beans:bean id="jpaConfigBean"
class="com.somepackage.DataJpaApplication" />
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<context:annotation-config />
<context:component-scan base-package="com.somepackage.*" />
<!-- Needed for transaction methods in controllers -->
<tx:annotation-driven />
<beans:bean id="ehCacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:shared="true" />
<beans:bean id="cacheManager"
class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cacheManager-ref="ehCacheManager" />
<cache:annotation-driven cache-manager="cacheManager" />
<task:scheduled-tasks>
<task:scheduled ref="runScheduler" method="run" cron="0 0 3 * * *" />
<task:scheduled ref="runScheduler" method="run"
initial-delay="0" fixed-rate="#{ T(java.lang.Long).MAX_VALUE }" />
</task:scheduled-tasks>
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven conversion-service="conversionService" />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
<beans:bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
<beans:bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<beans:property name="favorPathExtension" value="true" />
<beans:property name="favorParameter" value="false" />
<beans:property name="ignoreAcceptHeader" value="false" />
<beans:property name="mediaTypes">
<beans:value>
html=text/html
json=application/json
xml=application/xml
</beans:value>
</beans:property>
</beans:bean>
</beans:beans>
Not sure there is anything relevant in these files besides what I highlighted above, but added per request and for clarity.
How do I ensure that a call is being made to the OAuth2ProtectedResourceFilter when a request is sent with the oauth_token in the Authorization header?
It always passes through a filter if it is mapped properly
As mentioned, everything that you want to be secured, needs to go through a spring security filter:
Here a sample how a filter is mapped in front of the servlet (the spring MVC DispatcherServlet used for the authorization endpoints)
You could additionally map the same filter to any other servlet, for example to a jersey servlet you have configured.
In /WEB-INF/web.xml you need a filter-mapping like:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<servlet-name>spring-dispatcher</servlet-name>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-dispatcher-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
To ensure every call to '/*', or whatever pattern, is filtered you use http from the spring security namespace and a filter called OAuth2AuthenticationProcessingFilter, that will watch out for the Bearer Authorization header, you will need something like this in your /WEB-INF/spring-mvc-dispatcher-servlet.xml or where ever your spring security is configured:
<http pattern="/**"
create-session="never"
authentication-manager-ref="userAuthenticationManager"
access-decision-manager-ref="accessDecisionManager"
use-expressions="true">
<anonymous enabled="false" />
<custom-filter ref="oAuth2AuthenticationFilter" position="PRE_AUTH_FILTER" />
<access-denied-handler ref="oAuthAccessDeniedHandler" />
<intercept-url pattern="/**" access="isAuthenticated()" />
</http>
<beans:bean id="oAuth2AuthenticationFilter" class="org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter">
<beans:property name="authenticationManager" ref="userAuthenticationManager"/>
<beans:property name="authenticationEntryPoint" ref="oAuthAuthenticationEntryPoint"/>
</beans:bean>
We have a url-pattern of "/*" and requests get to our controller, but we always get a 404.
Here is our web.xml
<servlet>
<servlet-name>bro</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:mo/config/mo-spring.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>bro</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
mo-spring.xml:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="suffix" value=".jsp"/>
</bean>
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:resources mapping="/views/" location="/views/" />
A bit of the controller:
#RequestMapping(value="/signon", method=RequestMethod.GET)
public String signon(HttpServletRequest request) {
...
return "/WEB-INF/index";
}
If i use /xxx/* as the url-pattern in my web.xml everything works as expected, but we have a dojo app that we really don't want to modify that wants to talk to /* and not /xxx/*
You have bro as the servlet name, but reference brio as the servlet name for your url mapping in server.xml
If that's not the problem and you are talking about wanting your app to respond to http://yourserver/* instead of http://yourserver/yourcontext/* then you need to deploy your webapp as the root webapp for the server. Here's a question relating to that kind of configuration in tomcat Tomcat 6: How to change the ROOT application
edit: copied from my comment - If you are mapping DispatcherServlet to root in your webapp you will need the default-servlet configuration mentioned in http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-default-servlet-handler
I am trying to get my hands on Spring 3 web-mvc. I have a simple page link (you know.. <a href="xyz"> thing.
Somehow spring mvc doesn't like that.. eer.. well, my spring config is not working how i would like it to be.
I tried with DefaultRequestToViewNameTranslator but that didn't help. I think its something to do with what "Handler" spring dispatcher servlet chooses.. but I am not able to grasp those things yet. Log output did not help much either.
Can someone help?
Here is web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext.xml</param-value>
</context-param>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Reads request input using UTF-8 encoding -->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Handles all requests into the application -->
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
And spring config:
<!-- Scans the classpath of this application for #Components to deploy as beans -->
<context:component-scan base-package="com.mycompany.mvc" />
<!-- Configures the #Controller programming model -->
<mvc:annotation-driven />
<!-- Forwards requests to the "/" resource to the "welcome" view -->
<mvc:view-controller path="/" view-name="index"/>
<!-- Configures Handler Interceptors -->
<mvc:interceptors>
<!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de -->
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory -->
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:resources mapping="/images/**" location="/images/" />
<!-- Saves a locale change using a cookie -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" />
<!-- Application Message Bundle -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages/messages" />
<property name="cacheSeconds" value="0" />
</bean>
<!-- Automatic resolution of the view names.. Convention over configuration -->
<bean id="viewNameTranslator" class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator"/>
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/content/"/>
<property name="suffix" value=".jsp"/>
</bean>
And jsp where link is defined:
<li>flot integration</li>
And the log file output:
DEBUG o.s.web.servlet.DispatcherServlet:693 - DispatcherServlet with name 'Spring MVC Dispatcher Servlet' processing GET request for [/demo/flot]
WARN o.s.web.servlet.PageNotFound:947 - No mapping found for HTTP request with URI [/demo/flot] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'
DEBUG o.s.web.servlet.DispatcherServlet:674 - Successfully completed request
Controller should handle user's request and in your case no controller which mapped to this URL. When controller found, it performs some logic and returns view name which will be used to represent server's response. So, view name translator called only after controller and only for deduce full path to particular JSP file.
Try to add
<mvc:view-controller path="demo/flot" view-name="demo/flot"/>
(Also, you probably may try to omit view-name attribute, but I don't sure.)
Currently.. following worked..
Though the property /** might be an issue for me later when I add the controllers too.
But I can customize the .jsp file url
<bean id="handlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/**">urlFilenameViewController</prop>
</props>
</property>
</bean>
<bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
Using spring-webmvc 3.0.6.RELEASE this worked for me:
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<view-controller path="secure/*" view-name="secure/index"/>
<view-controller path="secure/extreme/*" view-name="secure/extreme/index"/>
<!-- Resolves views selected for rendering by #Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
Beans annotated with #Controller and #RequestMapping are called on the appropriate url, any url like secure/* and secure/extreme/* is handled by WEB-INF/views/secure/index.jsp and WEB-INF/views/secure/extreme/index.jsp respectively
I am using spring web 3.2.1 and I have only internal resolver and annotations based config. The jsp files view are accessible by default without using controller i.e not coded in any controller at return value of the mapped controller method. I guess there is some implicit rule.
Putting
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages/messages" />
<property name="cacheSeconds" value="0" />
</bean>
in application-context.xml resolved the issue for me. The view which does not have a controller(request mapping) will not load if we put these things in servlet.xml. I tried putting these things in application-context.xml and it worked for me. Thanks!!!
After version 3.1 there is WebMvcConfigurerAdapter, so you can put the mapping in configuration like this:
#Configuration
#EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
#Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("/index");
}
}
i am having issues loading a simple index.jsp page using spring 3 and tomcat 7.0
the error i recieve from the tomcat logs is this:
2011-02-07 11:36:18,510 DEBUG [org.springframework.web.servlet.DispatcherServlet] -
DispatcherServlet with name 'raceLeague' processing GET request for [/Online Racing League/index.htm]>
2011-02-07 11:36:18,515 WARN [org.springframework.web.servlet.PageNotFound] - No mapping found for HTTP request with URI [/Online Racing League/index.htm] in DispatcherServlet with name 'raceLeague'>
2011-02-07 11:36:18,515 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request>
Here is what my web.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<!-- Reads request input using UTF-8 encoding -->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Register and setup my servlet xml files here -->
<!-- Handles all requests into the application -->
<servlet>
<servlet-name>raceLeague</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>raceLeague</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
And here is my servlet-context.xml file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- Scans the classpath of this application for #Components to deploy as beans -->
<context:component-scan base-package="org.springframework.samples.mvc.basic" />
<!-- Configures the #Controller programming model -->
<mvc:annotation-driven />
<!-- Forwards requests to the "/" resource to the "welcome" view -->
<mvc:view-controller path="/" view-name="welcome"/>
<!-- Configures Handler Interceptors -->
<mvc:interceptors>
<!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de -->
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory -->
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- Saves a locale change using a cookie -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" />
<!-- Application Message Bundle -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages/messages" />
<property name="cacheSeconds" value="0" />
</bean>
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
Finally my index.jsp file
<%# include file="/WEB-INF/views/include.jsp" %>
<html>
<head><title>Online racing league</title></head>
<body>
<h1>Test</h1>
<table>
<tr>
<td>Upload a file</td>
<td>Display App list</td>
</tr>
</table>
</body>
</html>
i basically followed this example here so my projetc structure is similar to that http://blog.springsource.com/2009/12/21/mvc-simplifications-in-spring-3-0/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Interface21TeamBlog+%28SpringSource+Team+Blog%29
I am also using eclipse IDE
You also need a <mvc:default-servlet-handler/> to serve static resources when your servlet is bound to /.