<servlet>
<servlet-name>nav</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>nav</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
2、servlet.xml文件
<!-- 配置spring mvc -->
<bean id="defaultUrlHandlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="information.do">informationController</prop>
</props>
</property>
</bean>
<bean id="methodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName">
<value>action</value>
</property>
<property name="defaultMethodName">
<value>index</value>
</property>
</bean>
<bean id="paramMethodResolver"
class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName" value="method" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix">
<value>/WEB-INF/jsp/apps/nav/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- spring整合hibernate -->
要添加beans属性 default-autowire="byName" default-lazy-init="true"
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://10.0.50.102:3308/ad?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8" />
<property name="user" value="root" />
<property name="password" value="root" />
<property name="minPoolSize" value="1" />
<property name="maxPoolSize" value="10" />
<property name="initialPoolSize" value="1" />
<property name="maxIdleTime" value="60" />
<property name="acquireIncrement" value="2" />
<property name="idleConnectionTestPeriod" value="60" />
<property name="acquireRetryAttempts" value="3" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingDirectoryLocations">
<list>
<value>
classpath:/com/talelife/nav/domain/maps/
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLInnoDBDialect
</prop>
<!-- Create/update the database tables automatically when the JVM starts up-->
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">30</prop>
<prop key="hibernate.default_batch_fetch_size">30</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
</props>
</property>
</bean>
<!-- bean自定义类 -->
<bean id="informationController"
class="com.talelife.nav.web.controller.InformationController">
<property name="methodNameResolver" ref="paramMethodResolver" />
</bean>
<bean id="userManager" class="com.talelife.nav.service.UserManager"/>