Java Reference
In-Depth Information
5. <!-- Processes application requests -->
6. <servlet>
7. <servlet-name>bookstore</servlet-name>
8. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
9. <init-param>
10. <param-name>contextConfigLocation</param-name>
11. <param-value>/WEB-INF/spring/bookstore/bookstore-servlet.xml</param-value>
12. </init-param>
13. <load-on-startup>1</load-on-startup>
14. </servlet>
15.
16. <servlet-mapping>
17. <servlet-name>bookstore</servlet-name>
18. <url-pattern>*.html</url-pattern>
19. </servlet-mapping>
20.
21. <welcome-file-list>
22. <welcome-file>/list_book.html</welcome-file>
23. </welcome-file-list>
24. </web-app>
Lines 7 to 8 : DispatcherServlet is registered as a servlet called bookstore .
Line 10 : The Spring configuration file can be explicitly specified in the
contextConfigLocation servlet parameter to ask Spring to load the
configurations besides the default <servletname>-servlet.xml .
Listing 5-41 illustrates bookstore-servlet.xml .
Listing 5-41. bookstore-servlet.xml
1. <?xml version="1.0" encoding="UTF-8"?>
2. <beans:beans xmlns=" http://www.springframework.org/schema/mvc "
3. xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance " xmlns:beans=
" http://www.springframework.org/schema/beans "
4. xmlns:context=" http://www.springframework.org/schema/context "
5. xsi:schemaLocation=" http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
6. http://www.springframework.org/schema/beans http://www.springframework.org/schema/
beans/spring-beans.xsd
7. http://www.springframework.org/schema/context http://www.springframework.org/schema/
context/spring-context.xsd " >
8.
9. <!-- DispatcherServlet Context: defines this servlet's request-processing
10. infrastructure -->
11.
12. <beans:bean name="/list_book.html"
13. class="com.apress.bookstore.controller.BookController" />
14.
15. <!-- Resolves views selected for rendering by @Controllers to .jsp resources
16. in the /WEB-INF/views directory -->
17. <beans:bean
 
Search WWH ::




Custom Search