那位牛人能告诉小弟SpringMVC+Spring+hibernate的配置?
多谢了!
------解决方案--------------------
这个google下就出来了吧.
------解决方案--------------------
spring自带的例子就是最好 的教程。
------解决方案--------------------
我也正在学习,哈哈,要自己google出来才有收获呢!
------解决方案--------------------
- XML code
web.xml<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 配置Struts2的过滤器 --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 配置Spring监听器所需的参数 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:config/applicationContext.xml </param-value> </context-param> <!-- 配置监听器提供一个WebApplicationContext对象 --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
------解决方案--------------------
- XML code
<?xml version="1.0" encoding="UTF-8"?><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 http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/kjsb"></property> <property name="username" value="root"></property> <property name="password" value="long"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>com/ascent/po/User.hbm.xml</value> <value>com/ascent/po/ProjectCategory.hbm.xml</value> <value>com/ascent/po/Usergroup.hbm.xml</value> <value>com/ascent/po/Project.hbm.xml</value> <value>com/ascent/po/Expert.hbm.xml</value> <value>com/ascent/po/Useradmin.hbm.xml</value> <value>com/ascent/po/Unit.hbm.xml</value> </list> </property> </bean> <import resource="spring-service.xml" /> <import resource="spring-action.xml"/> </beans>