Skip to content

Instantly share code, notes, and snippets.

@jeevan-patil
Last active December 17, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeevan-patil/5597290 to your computer and use it in GitHub Desktop.
Save jeevan-patil/5597290 to your computer and use it in GitHub Desktop.
Spring application context xml file.
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans 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"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.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">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- Intercepting requests not to cache anything. -->
<mvc:interceptors>
<beans:bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<beans:property name="cacheSeconds" value="0" />
<beans:property name="useExpiresHeader" value="true" />
<beans:property name="useCacheControlHeader" value="true" />
<beans:property name="useCacheControlNoStore" value="true" />
</beans:bean>
</mvc:interceptors>
<!-- 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>
<context:component-scan base-package="com.transbank.online" />
<context:property-placeholder location="classpath:resources.properties"/>
</beans:beans>
@jeevan-patil
Copy link
Author

This is sample spring application context file. You can see how component scanning, loading properties file in context and adding cache headers in response is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment