Java Reference
In-Depth Information
Note Don't include the all-in-one jar (spring.jar) as it will throw java.lang.NoClassDefFoundError:
javax/naming/NamingException.
Server Configuration
Modify the web.xml file generated by Eclipse with the code in Listing 4-11, to use the
Spring DispatchServlet.
Listing 4-11. The web.xml file
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
" http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns=" http://java.sun.com/xml/ns/javaee" version="2.5">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-
class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Create the dispatcher-servlet.xml file in your /WEB-inf/ directory with the code from
Listing 4-12. The viewResolver bean allows you to swap out rendering models without
tying you to a specific view technology.
 
Search WWH ::




Custom Search