Java Reference
In-Depth Information
weather/
WEB-INF/
classes/
lib/*jar
weather-servlet.xml
web.xml
In the web deployment descriptor (i.e.,
web.xml
), you have to configure Spring MVC's
DispatcherServlet
.
<web-app version="2.4" xmlns="
http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
<servlet>
<servlet-name>weather</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>weather</servlet-name>
<url-pattern>
/
services
/*
</url-pattern>
</servlet-mapping>
</web-app>
In the preceding servlet mapping definition, you map all URLs under the
services
path to
DispatcherServlet
. Because the name of this servlet is
weather
, you create the following Spring MVC
configuration file,
weather-servlet.xml
, in the root of
WEB-INF
. In this file, you declare a bean for the
weather service implementation and export it as a Hessian service using
HessianServiceExporter
.
<beans xmlns="
http://www.springframework.org/schema/beans"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
<bean id="weatherService"
class="com.apress.springenterpriserecipes.weather.WeatherServiceImpl" />
<bean name="/WeatherService"
class="org.springframework.remoting.caucho.HessianServiceExporter">
<property name="service" ref="weatherService" />
<property name="serviceInterface"
value="com.apress.springenterpriserecipes.weather.WeatherService" />
</bean>
</beans>
Search WWH ::
Custom Search