最近学习玩了基于spring的jpetstore的代码,把自己在学习当中的一些心得整理出来
大家可以在csdn下载漠块中,下载到有关的代码,大家利用以写好的ant build.xml进行war包的生成,放到tomcat的webapps目录下,就可运行
这个框架是基于spring+struts+ibta
那么我们首先来看web.xml的配置
<?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>
<display-name>Spring JPetStore</display-name>
<description>Spring JPetStore sample application</description>
<!--
spring 加载的配置文件常
/WEB-INF/dataAccessContext-local.xml /WEB-INF/applicationContext.xml
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dataAccessContext-local.xml /WEB-INF/applicationContext.xml
</param-value>
</context-param>
<!--
- Loads the root application context of this web app at startup,
- by default from "/WEB-INF/applicationContext.xml".
- Note that it is preferable to use ContextLoaderListener in a servlet container
- that follows the Servlet 2.4 initialization order (most Servlet 2.3 containers do).
-
- Use WebApplicationContextUtils.getWebApplicationContext(servletContext)
- to access it anywhere in the web application, outside of the framework.
-
- The root context is the parent of all servlet-specific contexts.
- This means that its beans are automatically available in these child contexts,
- both for getBean(name) calls and (external) bean references.
-->
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!--
DispatcherServlet 是Spring MVC 中负责请求调度的核心引擎,所有的请求将
由此Servlet 根据配置分发至各个逻辑处理单元。其内部同时也维护了一个
ApplicationContext实例。
-->
<servlet>
<servlet-name>petstore</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<!--
struts的配置,这应该不用解释了吧
-->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet>
<servlet-name>caucho</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>4</load-on-startup>
</servlet>
<servlet>
<servlet-name>axis</servlet-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
<!--
servlet mapping映射
-->
<servlet-mapping>
<servlet-name>petstore</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>caucho</servlet-name>
<url-pattern>/caucho/*</url-pattern>
</servlet-mapping>
<!--
- Servlet mapping for Web Service remoting via Apache Axis
- (see server-config.wsdd for Axis configuration).
-->
<servlet-mapping>
<servlet-name>axis</servlet-name>
<url-pattern>/axis/*</url-pattern>
</servlet-mapping>
<!--
welcome文件
-->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>